如果你只是想分支master
指一個新的提交,其內容是相同的分支branch
,與master^
和master
是「改變一切,以滿足分支branch
的內容」之間的增量,這是很容易:
$ git checkout branch
$ git symbolic-ref HEAD refs/heads/master
$ git status # you'll see what you're about to commit, here
$ git commit # make that new commit
注意,對於master
分支歷史將不指branch
這裏。
如果你想提交的樣子改變一切的方式branch
外觀合併,這似乎這樣的伎倆,但我沒有測試得好:
$ git checkout master
$ git merge --no-commit -s ours branch # this sets up the merge
$ git rm -r . # this empties it out
$ git checkout branch -- . # this adds everything from branch
$ git status # again, just to see what you're about to commit
$ git commit # and maybe edit the message to note that you took "branch"
現在master^
是什麼高手用來看起來像和master^2
是branch
的小費。