Useful Git Commands Cheatsheet.
- git init
initializes a new Git repository
2. git add <files>
Adds files to the staging area.
3. git status
Used to check the state of the staging area, as well as the working directory
4. git log
Used to view the entire commit history.
5. git commit -m “message’
Used to commit files (locally) on the repository
6. git clone
Used to download existing code from a remote repository.
7. git branch
Used to list all the local branches on the machine
8. git merge <branch-name>
Merges the provided branch with the current working branch.
9. git branch <branch-name>
Used to create a new branch locally.
10. git branch -d <branch-name›
Used to delete a branch.
11. git branch -m <new-name
Used to rename the current working branch.
12. git checkout <branch-name›
It is used to switch from the current branch to another one.
13. git push <remote› <branch-name
Used to save all commits to the remote repository
14. git checkout -b ‹branch-name›
Creates a new branch and switches to the new one
15. git pull <remote>
Used to pull down all the updates from the remote repository.
16. git rm ‹file-name>
Used to remove a file from the working directory.
17. git stash
It is used to remove uncommitted changes temporarily.
18. git reset
Undo the changes to the local files, and restore to the last commit.
19. git diff
Displays the difference between files in two commits or between a commit and your current repository.