這就是爲什麼它很重要很好地管理你的分支,尤其是使用主題分支並向上合併。
你應該做一個主題分支修復,從中將需要修復的所有分支的共同祖先分叉,然後將其合併到主,貝寶:
x - x - x - x ------------- X (master)
|\ |
| x - x - x ---- X (paypal) |
\ / /
x (bugfix) ---------------
如果你已經取得了你的bug修正,你誤使它的主人,而不是從適合的合併基礎,並在掌握歷史尚未發佈,你應該摘櫻桃或重訂其到合適的位置:
# If the bugfix commit is not at the tip of master, you can rebase to get it there:
git rebase -i <commit before the bugfix> master
# rearrange the list of commits to put the bugfix at the tip, save and quit
# Now either cherry-pick or rebase the commit to the right place
# (rebase is easier if the bugfix is actually several commits)
# Cherry-pick
# make a branch and cherry-pick
git checkout -b bugfix <SHA1 of merge base>
git cherry-pick <SHA1 of bugfix>
# remove the commit from master, assuming it's still on the tip
git checkout master
git reset --hard master^
# or rebase
# make the bugfix branch (assuming it's still on the tip)
git branch bugfix master
# and remove the commit from master (assuming it's still on the tip)
git checkout master
git reset --hard master^ # or if the bugfix is composed of n commits, master~n
# rebase the bugfix branch to the right place
git rebase --onto <SHA1 of merge base> master bugfix
如果歷史有已經公佈,所有你能做的就是櫻桃挑bug修正到貝寶分支,記得把事情做對,下一次:
git checkout paypal
git cherry-pick <SHA1 of bugfix>
正如其他人所說,你可能不希望有一個缺少所有文件的分支。如果您確實想單獨跟蹤插件,它應該是一個單獨的存儲庫,可能包含在主項目中的子模塊中。如果你不希望它是單獨的,那麼當然,它可以有自己的開發分支,但作爲項目存儲庫的一個分支,該分支應該包含整個項目,而不僅僅是一個插件。 – Cascabel 2010-06-24 14:55:12