合并后的Git壁球历史 [英] Git squash history after merge
问题描述
我将一个大型项目的上游与我的本地git回购合并。在合并之前,我有一小段历史很容易阅读,但在合并之后,我的回购中有大量历史记录。我没有必要从上游回购所有历史提交。
在我希望保留的上游合并之后还有其他提交。如何将上游合并的历史压缩为一个提交,同时保持上游合并后提交的内容? >我最终使用的解决方案是手动重新创建历史记录。我这样做主要是因为我不想花太多时间寻找一个优雅的解决方案,并没有太多的历史(大约30次提交,我不得不手动合并)。
所以,我在合并巨大的上游之前创建了一个分支:
git checkout -b remove-history -fix<合并前的提交ID>
然后使用 - squash $ c重新合并上游$ c $> option。
git merge --squash< upstream tag>
然后在旧分支合并之后手动樱桃挑选提交(数量巨大
git cherry-pick<提交ID>
将所有这些提交合并到我的 remove-history-fix 分支后,我删除了具有上游历史记录的分支。
git分支-D<上游历史分支>
I merged an upstream of a large project with my local git repo. Prior to the merge I had a small amount of history that was easy to read through, but after the merge a massive amount of history is now in my repo. I have no need for all the history commits from the upstream repo.
There have been other commits made after this upstream merge that I would like to keep. How do I squash all that history that was merged from the upstream into one commit while keeping the commits made after the upstream merge?
The solution I ended up using was to manually recreate the history. I did this mainly because I didn't want to spend too much time looking for an elegant solution and there wasn't that much history (around 30 commits I'd have to manually merge).
So, I created a branch before I merged the huge upstream:
git checkout -b remove-history-fix <commit ID before merge>
Then re-merged the upstream using the --squash
option.
git merge --squash <upstream tag>
Then manually cherry-picked the commits after the merge from the old branch (the one with the huge amount of upstream history).
git cherry-pick <commit ID>
After all those commits were merged into my remove-history-fix branch, I removed the branch with the upstream history.
git branch -D <upstream-history-branch>
这篇关于合并后的Git壁球历史的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!