git重写历史(rebase旧分支?)

时间:2017-07-02 10:32:38

标签: git rebase revision-history

到目前为止,我尝试在git存储库中重写我的历史记录并取得了一些成功。 我尝试使用rebasing来删除每个提交中的大文件,我一定做错了,因为我最终得到了这个奇怪的形状历史。

*   0758bb3 - (HEAD -> master, origin/master, origin/HEAD)
|\  
| * 1ff4a51
| * f33555f
(... a bunch of commits in the right-hand-size branch only)
| * af4b7bf
| * a9bf8d0
| * f22fae8
* | 68bd9eb
* | 2e29133
|/  
* fbef4bf

我想将其转换为:

*   0758bb3 - (HEAD -> master, origin/master, origin/HEAD)  
* 1ff4a51
* f33555f
(...)
* af4b7bf
* a9bf8d0
* f22fae8
* 68bd9eb
* 2e29133
* fbef4bf

我想这样做的方式应该看起来有点像

git checkout f22fae8
git rebase 68bd9eb
???
git push --force origin master

但考虑到我对#34; refasing"现在,我无法掌握现有的信息来做到这一点。 如果问题已在某处得到解答,我很抱歉,我没有找到它(可能是因为我不知道应该用什么词来描述这种情况:/)。 非常感谢任何可以帮助我的人:)

1 个答案:

答案 0 :(得分:0)

我不知道你上面要做什么。如果你合并分支,它看起来像上面那样,那么你已经拥有了你想要的东西。但是如果你希望它使用rebase看起来不同,那么你将拥有完全不同的提交。如果你正在变基础,那么你基本上是在创建新的提交,这些提交与之前存在的提交相同。那么那么提交历史看起来就不一样了。这是一个将上述结构转换为您正在寻找的结果的示例 - 但是使用了新的提交。

// First set up another branch where you can safely rebase

git checkout fbef4bf
git checkout -b rebase-point

// now switch to the place you want to rebase from:

git checkout master
git rebase rebase-point    

// if satisfied, set the master branch to point to the 0758bb3 commit equivalent (remember we are rebasing so it won't be the same commit).

git reset --hard rebase-point 
相关问题