自己總結:
01.若在提交過程中有沖突,解決沖突后,git add .
git rebase —continue
git push for
02.git rebase vs git merge
git rebase b (合並分支b)
解決沖突
git rebase —continue
git rebase —skip//跳過沖突
git rebase —absort//取消合並
1,在dev分支開發
git add .
git commit -am ''
git pull —rebase //解決沖突
git push origin dev:refs/for/dev
2,線上線下測試
1) mvn debug on jetty
2) curl -H "***: ***" -H "***: ***" 'http://***/***/***?***=***&***=***'
3,若commit之后想要返回
git log //查看需要退到哪個commitId之前
git reset commitId
git push
若git add .
git commit
git push
則幾乎是把之前做的所有改動真的全部取消
4,若已經git reset —hard commitId
回到了上次改動的地方,
git pull將上次的改動再拉下來
git revert commitId
git commit
git push
git revert 是生成一個新的提交來撤銷某次提交,此次提交之前的commit都會被保留
git reset 是回到某次提交,提交及之前的commit都會被保留,但是此次之后的修改都會被退回到暫存區
網上搜集的有用的實例:
A) 回滾add操縱
引用
$ edit (1)
$ git add frotz.c filfre.c
$ mailx (2)
$ git reset (3)
$ git pull git://info.
example.com/ nitfol (4)
B) 回滾最近一次commit
引用
$ git commit ...
$ git reset --soft HEAD^ (1)
$ edit (2)
$ git commit -a -c ORIG_HEAD (3)
C) 回滾最近幾次commit,並把這幾次commit放到叫做topic的branch上去。
引用
$ git branch topic/wip (1)
$ git reset --hard HEAD~3 (2)
D) 永久刪除最后幾個commit
引用
$ git commit ...
$ git reset --hard HEAD~3 (1)
E) 回滾merge和pull操作
引用
$ git pull (1)
Auto-merging nitfol
CONFLICT (content): Merge conflict in nitfol
Automatic merge failed; fix conflicts and then commit the result.
$ git reset --hard (2)
$ git pull . topic/branch (3)
Updating from 41223... to 13134...
Fast-forward
$ git reset --hard ORIG_HEAD (4)
F) 在被污染的working tree中回滾merge或者pull
引用
$ git pull (1)
Auto-merging nitfol
Merge made by recursive.
nitfol | 20 +++++----
...
$ git reset --merge ORIG_HEAD (2)
G) 被中斷的工作流程
在實際開發中經常出現這樣的情形:你正在開發一個大的feature,此時來了一個緊急的bug需要修復,但是目前在working tree中的內容還沒有成型,還不足以commit,但是你又必須切換的另外的branch去fix bug。請看下面的例子
引用
$ git checkout feature ;# you were working in "feature" branch and
$ work work work ;# got interrupted
$ git commit -a -m "snapshot WIP" (1)
$ git checkout master
$ fix fix fix
$ git commit ;# commit with real log
$ git checkout feature
$ git reset --soft HEAD^ ;# go back to WIP state (2)
$ git reset (3)
(H) Reset單獨的一個文件
假設你已經添加了一個文件進入index,但是而后又不打算把這個文件提交,此時可以使用git reset把這個文件從index中去除。
引用
$ git reset -- frotz.c (1)
$ git commit -m "Commit files in index" (2)
$ git add frotz.c (3)
(I) 保留working tree並丟棄一些之前的commit
假設你正在編輯一些文件,並且已經提交,接着繼續工作,但是現在你發現當前在working tree中的內容應該屬於另一個branch,與這之前的commit沒有什么關系。此時,你可以開啟一個新的branch,並且保留着working tree中的內容。
引用
$ git tag start
$ git checkout -b branch1
$ edit
$ git commit ... (1)
$ edit
$ git checkout -b branch2 (2)
$ git reset --keep start (3)