Git is a distributed version control software. This article introduces a typical learning path for this tool and lists the key commands you must know well.

Independent basic use

As a version management tool to preserve revision history only, you need to familiarize yourself with the following commands when not considering collaboration with others and multi-version maintenance.

git init git clone <repository> git status git add <file> git add --all git commit git remote add git remote set-url git  remote -v git push <repository> <branch> git pull <repository> <branch>Copy the code

Key configuration

As you use more and more of them you will find that some of them are cumbersome, so you need to learn some key configurations to satisfy your own differences.

git log 
git checkout <file>
git reset <file> 
git reset --hard 
git clean -f 
git rm <file> 
git config --global user.name
git config --global user.email
git stash
git stash apply
git stash clear 

Copy the code

Multi-person collaborative use

When you need to maintain a project with others, you need to have the ability to check out branches, create branches, merge branches, view revision history, and so on.

git merge
git branch
git checkout <branch>
git checkout -b
git blame <file>
git rebase
git push --force-with-lease (DANGEROUS)

Copy the code

Version manager

If you are versioning a project, you will need to understand more specialized operations, including looking at branches in more detail, comparing branches, restoring versions, changing revisions, fixing version problems, and so on.

git commit --amend
git rebase -i
git prune
git fetch
git remote prune
git checkout HEAD/HEAD~1/<commit hash>
git diff <commit hash 1> <commit hash 2>
git revert <commit hash>
git reflog
git-filter-branch
git-filter-repo
git bisect

Copy the code

Copyright notice, this article first in digital magic box www.dm2box.com/ welcome to reprint.