- 一個圖看懂git merge合并和git merge --no-ff(禁用
Fast forward
模式)區別
git merge --no-ff 和 git merge.png -
git stash
: 備份當前的工作區的內容,從最近的一次提交中讀取相關內容,讓工作區保證和上次提交的內容一致。同時,將當前的工作區內容保存到Git棧中。
git stash pop
: 從Git棧中讀取最近一次保存的內容,恢復工作區的相關內容。由于可能存在多個Stash的內容,所以用棧來管理,pop會從最近的一個stash中讀取內容并恢復(恢復并刪除)。
git stash list
查看保存的工作現場
git stash apply
恢復工作現場
git stash drop
刪除stash內容 -
git branch -D <name>
強行刪除未合并的分支 -
git checkout [file]
恢復暫緩區的指定文件到工作區 -
git checkout .
恢復上一個commit -
git reset --hard [commit]
還原暫緩區和工作區到某個commit狀態(git reset --hard HEAD
工作區恢復到上一次commit狀態)【--hard
代表丟棄工作區的修改,--soft
代表保留工作區的修改】 -
git reset HEAD [file]
還原暫緩區 -
git checkout -- file
取消對文件的修改(從暫緩區覆蓋工作區)
git merge和git rebase
-
git remote add origin ‘XXX’
添加源 -
git push origin master
推送到遠程(git push -f orgin master
強制推送) -
git push origin :branchName
刪除遠程分支 -
git branch -m old new
重命名分支