This article is used to record some records in the process of bloggers using git, such as what commands to use instead of what they want to do.
1. Turn on colors in git command output
git config --global color.ui true
2. The files already in the staging area cannot be changed by using git diff directly, that is to say, git diff is used to diff with the workspace by default, so:
Comparison of scratch area and head:
git diff cached
Workspace comparison with original version:
git diff HEAD
3. Use log in a more neat way
implement:
git config --global alias.lg = log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit
After that run git lg directly
4. Install git 2.0
When installing git2.0 on centos, you may encounter various things that are not installed. If you use perl to install various dependent packages, you will be very successful. You can install it with yum, but you don't need to install it without prompting. It is best to search with yum first. Then install perl-xxx or something.
5. Update the latest code to the local code repository
git pull origin
git fetch origin
6. If there are too many branches and you don’t know which branch you have a commit to, you can use the following command to make all the branch commits:
git log --all --author xxx
7. If you want to put the changes of a commit into another branch, you can use the following command:
git cherry-pick xxxx(commit id)
8. Automatically withdraw the most recent merge
git reset --merge ORIG_HEAD