git add
git commit
git commit -am
git branch newBranch(新建分支)
git checkout newBranch(切换分支)
git checkout -b newBranch(新建并切换)
git merge newBranch (把newBranch合并到当前分支)
git rebase master newBranch(把newBranch变基到master)
git checkout HEAD^(检出HEAD的父节点)
git checkout HEAD^2(检出HEAD第二个父节点,区别~)
git checkout master^(检出master的父节点)
git checkout master^^(检出master的父父节点)
git checkout HEAD~4(检出HEAD的第4个父节点)
git branch -f master HEAD~3(把master分支强制切换到HEAD的第三个父节点)
git reset HEAD~1(重置到上一次提交)
git revert HEAD(重做本次提交)
git cherry-pick commitId(取commitId提交到当前分支)
git rebase -i HEAD~4(交互式变基HEAD到HEAD前四次提交)
git commit --amend()
git clone
git checkout origin/master(切换到远端的本地分支)
git fetch(拉取远端分支)
配合git fetch
git cherry-pick origin/master
git rebase origin/master
git merge origin/master
git pull(拉取并merge)
git pull --rebase (拉取并rebase)
git push(推送本地)
git checkout -b newBranch origin/master(远端新建本地分支)
git branch newBranch
git branch -u origin/master newBranch(关联本地和远程分支)
git push
<remote> <place>
git push origin master(本地mastr到origin的master分支)
git push origin
<source>:<destination>
git push origin newBranch:master(提交本地的newBranch分支代码到origin的master分支,远程分支不存在会被创建)
git fetch origin
<source>:<destination>
git fetch origin newBranch (从远端newBranch分支拉取代码,放到本地的origin/newBranch分支)
git fetch origin newBranch/master (从远端newBranch分支拉取代码,放到本地的master分支上)
git push origin :newBranch(删除远程newBranch仓库)
git fetch origin :newBranch(本地新建一个空newBranch仓库)
git pull origin master:newBranch(本地新建一个newBranch分支,从master拉取代码,合并到newBranch,最后merge到当前分支)
← hook工具