本文同步自個人博客JoeRay61git
本文主要是用來記錄一些在git管理的項目中常見的場景及其對應的命令,方便本身和他人使用的時候快速查詢。若有不對,敬請指正。shell
git help [command]
git status
git clone [url]
git init
git add [file-name]
git commit
git rm [file-name]
git rm -f [file-name]
git rm --cached [file-name]
git mv [old-name] [new-name]
git diff --cached
git diff [path/to/file]
git branch
git branch -r
git branch -a
git branch [branch-name]
git checkout [branch-name]
git merge [branch-name]
git branch -d [branch-name]
git branch -D [branch-name]
git reset --hard HEAD
git log
git log -p
git log --stat
git diff [branch-name]
git diff [branch-name] -- [path]
git commit --amend
git reset HEAD [file-name]
git checkout -- [file-name]
git remote
git remote -v
git remote add [remote-name] [url]
git fetch [remote-name] [branch-name]
git push [remote-name] [branch-name]
git remote show [remote-name]
git remote rename [old-name] [new-name]
git remote rm [remote-name]
git tag
git tag -l [keyword]
git tag [tag-name]
git tag -a [tag-name] -m [msg]
git tag -a [tag-name] [hash]
git show [tag-name]
git push [remote-name] [tag-name]
git push [remote-name] --tags
git checkout b git rebase a
git stash
git stash list
git stash apply [stash-name]