git commands
Format
[command] : [explain]
[explain] contains symbol:
- + : with
- – : link
- =- : change to
- =+ : attach to
- == : rename as
- => : combine to
- ?-? : link chain
- VS. : compare
- Covered : covered to
- Track: track remote branch
- And : and
Example
Local
- git init : create .git directory
- git add . : untracked/modified =- tracked/staged
- git commit
- git commit : tracked/staged =- unmodifiled
- git commit –amend : tracked/staged =+ last unmodifiled == unmodifiled
- git status : check status
- git log : show commit log
- git diff
- git diff : tracked/staged VS. modified
- git diff –cached : unmodified VS. tracked/staged
- git diff HEAD : unmodified VS. untracked/modified
- git reset
- git reset : unmodified Covered tracked/staged
- git reset –hard HEAD : unmodified Covered tracked/staged And modified
- git reset –hard HEAD^ : last unmodifiled == unmodified Covered tracked/staged And modified
- git merge OTHER : OTHER + last unmodified => unmodified
- git rebase
- git rebase OTHER (HEAD) : OTHER – last unmodified == unmodified
- git rebase –interactive HEAD~4 : HEAD~4 – ?-? == unmodified
- git checkout : change branch
- git branch
- git branch OTHER : unmodified == OTHER
- git branch -f OTHER HEAD : OTHER == unmodified
- git revert HEAD (only in remote): last unmodified – unmodified – last unmodified == unmodified
- git cherry-pick OTHER1 OTHER2 : unmodified – OTHER1 – OTHER2 == unmodified
- git tag TAG OTHER : OTHER(TAG)
Remote
- git clone : remote Covered origin And local
- git fetch
- git fetch : remote Covered origin
- git fetch origin OTHER(:HEAD) : remote OTHER Covered local HEAD
- git fetch origin :OTHER : git branch OTHER
- git pull
- git pull (…) : git fetch (…); git merge origin
- git pull (…) –rebase : git fetch (…); git rebase origin
- git push
- git push (origin) (HEAD(:OTHER)) : local HEAD Covered remote OTHER And origin OTHER
- git push origin :OTHER : delete local OTHER And origin OTHER And remote OTHER
- git checkout -b OTHER1 origin/OTHER2 : local branch OTHER1 Track remote branch OTHER2
- git branch -u origin/OTHER (HEAD) : local branch HEAD Track remote branch OTHER
本文采用 CC BY-NC-SA 3.0 Unported 协议进行许可