我有以下资料库:
* d9da0f2 (HEAD, master) Fifth
| * bf3b476 (branch1) branch1 first
|/
* 13f93d5 Fourth
* 94f2fa1 Third
* 5333eb2 Second
* be69a71 First
我所要做的就是做一些事情来获得以下结构:
* d9da0f2 (HEAD, master) Fifth
| * bf3b476 (branch1) branch1 first
|/
* ?13f93d5? Reworded commit, with all the other commmits squashed/fixuped into it
我试过以下:
git checkout 13f93d5
git rebase -i --root
reword be69a71 First
fixup 5333eb2 Second
fixup 94f2fa1 Third
fixup 13f93d5 Fourth
但结果是:
* commit a6a091c9bc495b9de5ca51dee5d0032454e669db (HEAD)
Author: frigo <frigo@dev>
Date: Fri Nov 7 20:18:55 2014 +0100
First reworded
* commit d9da0f2f273b91913ac241f3b6b034ef7babf1d1 (master)
| Author: frigo <frigo@dev>
| Date: Fri Nov 7 20:24:18 2014 +0100
| Fifth
| * commit bf3b476491547523321c765857de2097f77cdbd5 (branch1)
|/ Author: frigo <frigo@dev>
| Date: Fri Nov 7 20:23:54 2014 +0100
| branch1 first
* commit 13f93d5ca898a043d37d704d397d34cf1f133a05
| Author: frigo <frigo@dev>
| Date: Fri Nov 7 20:20:12 2014 +0100
| Fourth
* commit 94f2fa1bb654288860c6af34c0cc9ff1267e0e72
| Author: frigo <frigo@dev>
| Date: Fri Nov 7 20:19:57 2014 +0100
| Third
* commit 5333eb26b57b038b3b4fdf2cb91590c0254b4024
| Author: frigo <frigo@dev>
| Date: Fri Nov 7 20:19:24 2014 +0100
| Second
* commit be69a7194413d9760b9f8930edf79afe7095b716
Author: frigo <frigo@dev>
Date: Fri Nov 7 20:18:55 2014 +0100
First
正如我所料,以下内容没有区别:
git diff 13f93d5 a6a091c
但是,在重新提交的提交之后,所有提交仍然附加到旧的提交层次结构。
我还尝试创建一个移植文件,其中没有13f93d5
的父级并且正在运行git filter-branch
以“将其雕刻成石头”,但这仍然留给我git --all
的历史记录。
答案 0 :(得分:1)
git checkout aSHA1表示您处于分离的HEAD模式。
您应该使用以下内容制作互动式基础:
git checkout master
git rebase -i --root
在选择d9da0f2(当前主HEAd)时执行你所做的reword和fixup
请注意,branch1
搁浅:
# after the rebase:
git branch -f branch1 master~1
git checkout branch1
git cherry-pick bf3b476