创建本地仓库
- git init
跟踪
- git add
- git rm
- git rm --chache
暂存
- git add
- git reset HEAD
- git commit -m
- git commit -am
- git reset head~ --soft
查看文件状态
- git status 红色是修改但没暂存
- git diff
- git log
- git log --all
- git log --pretty
- git log --graph
- git log --all --graph
远程仓库
- git remote add orgin
- git remote
- git remote rename orgin origin
- git push origin master
- git puhsh -u origin master
- git fetch
- git pull(git fetch+git merge)
- git pull --rebase(git fetch+git rebase)
SSH
- cd ~/.ssh
- ssh-keygen -t rsa -b 4096 -C “@qq.com”
- cat test.pub
分支
- git log
- git status
- git branch --list
- git branch newbranch
- git checkout newbranch
- git checkout -b newbranch2
- git merge newbranch
- git checkout -b newbranch3 origin/newbranch3
- git checkout --track origin/newbranch
- git checkout HEAD^
- git branch -f main HEAD~3
贮藏
- git stash
- git stash push
- git stash apply
- git stash list
- git stash apply stash@{2}
- git stash pop
- git stash drop stash@{0}
重置
-
git reset HEAD~
-
git reset HEAD^
-
git rebase main
-
git rebase -i C3 C5
-
git rebase -i HEAD~4
-
git revert HEAD
-
git cherry-pick C3 C4 C7
-
git fetch
-
git rebase o/main或git merge o/main或git pull --rebase或git pull
-
git push