This page contains a list of Git commands that I know easily but are hard to remember
- Push in a series of commits and rewrite the history by writing them as one
- Make a commit located in a separate branch and apply the same changes on the current branch
- Restore the state of the file to the last commit (revert changes)
- Beautiful graph showing submission history
- Get more beautiful logs
- Get a shorter state
- Pull request at local checkout
- List submissions involving specific documents
- List submissions involving specific documents, including submissions
- List repository contributors sorted by number of commits
- Undo the last commit you pushed to the remote
- Select all the changes you haven’t committed, and create a new branch
- Stop tracking files, but keep them in the file system
- Get the name of the branch that made a specific commit
Push in a series of commits and rewrite the history by writing them as one
git rebase -i
This will put you into an interactive basic adjustment tool.
Types ofs
Applicationsquash
Submit with the previous one. repeats
The number of submissions required for the command.
Make a commit located in a separate branch and apply the same changes on the current branch
Single submission:
git cherry-pick <commit>
For multiple submissions:
git cherry-pick <commit1> <commit2> <commit3>
Restore the state of the file to the last commit (revert changes)
git checkout -- <filename>
Beautiful graph showing submission history
git log --pretty=format:"%h %s" --graph
Get more beautiful logs
git log --pretty=format:"%h - %an, %ar : %s"
Get a shorter state
git status -s
Pull request at local checkout
git fetch origin pull/<id>/head:<branch>
git checkout <branch>
List submissions involving specific documents
git log --follow -- <filename>
List submissions involving specific documents, including submissions
git log --follow -p -- <filename>
List repository contributors sorted by number of commits
git shortlog -s -n
Undo the last commit you pushed to the remote
git revert -n HEAD
Select all the changes you haven’t committed, and create a new branch
git checkout -b <branch>
Stop tracking files, but keep them in the file system
git rm -r --cached
Get the name of the branch that made a specific commit
git branch --contains <commit>
More git tutorials:
- A Git cheat sheet
- Git workflow to manage the work of multiple branches
- The easy way to deal with Git sub-repositories
- Incomplete list of excellent Git tutorials
- Introduction to GitHub Developers
- The complete Git guide
- How to use git bisect to find errors
- How to make the first pull request on GitHub
- How to update Git branch from another branch
- I published the password/API key on GitHub
- Squash Git commit
- How to delete the Git remote