[英]Why I can rebase but I can't merge in git?
也許你可以糾正我,我擔心這可能很簡單:
所以,根據我的理解,git merge和git rebase是實現相同目標的兩種不同方式:因此,如果我可以rebase,我也可以合並。
現在,我正在嘗試將mybranch與主人合並,但是當我從mybranch那里做到時
git merge master
我得到了“已經是最新的”,雖然有幾個不同之處,當我這樣做時
git rebase master
它開始變基礎了。 另外,當我修復一些沖突時,添加固定文件並執行
git rebase --continue
我收到了這個錯誤:
Applying: my commit xxx
No changes - did you forget to use 'git add'?
If there is nothing left to stage, chances are that something else
already introduced the same changes; you might want to skip this patch.
When you have resolved this problem, run "git rebase --continue".
If you prefer to skip this patch, run "git rebase --skip" instead.
To check out the original branch and stop rebasing, run "git rebase --abort".
這是目前的情況:
* 179dcec (origin/myBranch, myBranch) Merge branch 'myBranch' of https://github.com/repo/myRepo into myBranch
|\
| * ee8525b Merge branch 'myBranch' of https://github.com/repo/myRepo into myBranch
| |\
| | * 975a4f2 changed the name
| | * 153450b Fixed jshint problems
| | * b6eee76 Merge branch 'master' of https://github.com/repo/myRepo into myBranch
| | |\
| | * | 70e3139 Fixed a bug
| | * | 715d308 fixed a bug
| | * | ccfd06a Merge branch 'master' of https://github.com/repo/myRepo into myBranch
| | |\ \
| | * | | 03c87f2 deleted useless test file
| | * | | dd09f21 Testing
| | * | | 214af56 Integrated the unified DB
| | * | | 43242ff Merge branch 'master' of https://github.com/repo/myRepo into myBranch
| | |\ \ \
| | * \ \ \ f9ecae6 Merge branch 'master' of https://github.com/repo/myRepo into myBranch
| | |\ \ \ \
| | * | | | | 626bb26 Error handler integrated
| | * | | | | ac92b60 Merge branch 'master' of https://github.com/repo/myRepo into myBranch
| | |\ \ \ \ \
| | * \ \ \ \ \ 9f6c0b2 Merge branch 'master' of https://github.com/repo/myRepo into myBranch
| | |\ \ \ \ \ \
| | * | | | | | | b09ce40 added DB error handler
| * | | | | | | | d3ebb13 changed the name
| * | | | | | | | f68281e Fixed jshint problems
| * | | | | | | | 31cb0b3 Fixed a bug
| * | | | | | | | 74d8735 fixed a bug
| * | | | | | | | cb3e6e2 deleted file
| * | | | | | | | 80d7164 Testing
| * | | | | | | | 191fb77 Integrated the unified DB
| * | | | | | | | 2af7142 Error handler integrated
| * | | | | | | | fff8b2f added DB error handler
| | |_|_|_|_|_|/
| |/| | | | | |
* | | | | | | | 730b412 deleted useless test file
這里發生了什么?
從我如何理解git merge和git rebase是實現相同目標的兩種不同方式:因此,如果我可以rebase我也可以合並
確實,rebase和merge將(假設任何合並沖突以相同的方式得到解決)在結果提示中結束相同的內容 - 但是rebase為每個重新提交的提交做出新的提交,順序重放每個提交的更改base commit的內容( master
在這里)。 Merge保留了當前歷史記錄,並添加了一個新提交,其中包含每個分支上所有提交的更改,因為合並基礎合並為一個新的提交。
如果你記住每個提交都是完整內容,這更容易理解:對於merge,git只是將左分支的尖端與合並基礎區分開來,將右分支的尖端與合並基礎區分開來,將所有提交組合在一起看起來獨立的帥哥,讓你去挑選任何看起來可能會發生沖突的帥哥。 如果你不得不這樣,那就是你自己做的差異/補丁序列。
因此,您可以將rebase視為追溯合並。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.