0% found this document useful (0 votes)
2 views3 pages

Github CheatSheet

This document provides a concise guide on essential Git commands for managing a project repository. Key commands include initializing a repository, connecting to a remote repository, staging files, committing changes, pushing to remote, and managing branches. Additional commands for resetting, pulling updates, fetching, and stashing changes are also covered.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views3 pages

Github CheatSheet

This document provides a concise guide on essential Git commands for managing a project repository. Key commands include initializing a repository, connecting to a remote repository, staging files, committing changes, pushing to remote, and managing branches. Additional commands for resetting, pulling updates, fetching, and stashing changes are also covered.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

SO, LET'S GIT STARTED:

1. GIT INIT

THIS COMMAND IS USED TO INITIALIZE A PROJECT AS AN EMPTY


GIT REPOSITORY.

2. GIT REMOTE ADD ORIGIN

THIS COMMAND IS USED TO CONNECT A PROJECT TO A REMOTE


REPOSITORY.

GIT REMOTE ADD ORIGIN


HTTPS://[Link]/DEBAJYOTI14/[Link]

3. GIT REMOTE

THIS COMMAND IS USED TO SHOW CONNECTED REMOTE


REPOSITORY.

4. GIT ADD

THIS COMMAND IS USED TO STAGE ALL UNTRACKED AND MODIFIED


FILES. GIT ADD . TO STAGE ALL UNSTAGED & MODIFIED FILES.

GIT ADD [Link]

5. GIT STATUS

THIS COMMAND IS USED TO SHOW THE STATUS OF YOUR FILES IN


THE REPOSITORY LIKE- UNTRACKED, MODIFIED ETC.
6. GIT COMMIT

THIS COMMAND IS USED TO COMMIT THE STAGED FILE AND ALSO


ALLOWS YOU TO WRITE A COMMIT MESSAGE FOR REFERRING.

GIT COMMIT -M "[Link] FILE IS ADDED"

7. GIT PUSH -U ORIGIN

THIS COMMAND IS USED TO PUSH COMMITTED FILES TO THE


REMOTE REPOSITORY AND ALSO IN THE SPECIFIED BRANCH.
THIS -U TAG IS NEEDED FOR THE FIRST TIME PUSHING THE FILE
TO THE REMOTE REPOSITORY. THEN YOU ONLY NEED TO WRITE
GIT PUSH ORIGIN/UPSTREAM BRANCH NAME. USE UPSTREAM IF
YOU WANT TO PUSH IN SOMEONE'S REPOSITORY.

GIT PUSH ORIGIN MAIN

8. GIT RESET

THIS COMMAND IS USED TO UNSTAGE COMMITS. YOU CAN ALSO


ADD THE COMMIT ID AFTER GIT RESET TO UNSTAGE THE
SPECIFIC COMMIT. ALWAYS USE THE BELOW COMMIT ID WHICH
YOU WANT TO DELETE.

GIT RESET <COMMIT-ID>

9. GIT PULL

THIS COMMAND IS USED TO PULL THE UPDATED CODEBASE TO


YOUR LOCAL REPOSITORY.
GIT RESET <COMMIT-ID>
10. GIT BRANCH

THIS COMMAND IS USED TO SHOW THE CURRENT BRANCH.

11. GIT CHECKOUT -B BRANCH-NAME

THIS COMMAND IS USED TO CREATE AND MOVE TO THE BRANCH


INSTANTLY.

12. GIT CHECKOUT BRANCH-NAME

THIS COMMAND IS USED TO MOVE BETWEEN BRANCHES.

13. GIT BRANCH -A

THIS COMMAND IS USED TO SHOW ALL THE BRANCHES IN YOUR


LOCAL REPOSITORY.

14. GIT FETCH

THIS COMMAND IS USED TO FETCH THE MOST UPDATED VERSION


OF YOUR REMOTE REPOSITORY TO YOUR LOCAL REPOSITORY.

15. GIT STASH

GIT STASH SAVES THE UNCOMMITTED CHANGES LOCALLY,


ALLOWING YOU TO MAKE CHANGES, SWITCH BRANCHES, AND
PERFORM OTHER GIT OPERATIONS.

You might also like