admin管理员组文章数量:1404927
I'm currently cleaning up my repo from old unused big files and random branches left hanging around. This has created some empty commits which I've been able to delete from git. However, I can't delete this empty merge commit. See attached image of my git tree. I have 2 branches other than main (branching off higher up in the git tree) called alex and pierre.
See attached image :
I've tried this git rebase command :
git rebase --onto 129294f9cda35e8c5861122668351519318fccec de782492dfa62b19d35a8c703a241a793475ff08
It gave me weird conflicts on the .gitignore file. After resolving that the rebase still failed and I was left with a very weird looking git tree with my pierre branch all on it's own. I had to run git rebase --abort
. I think the rebase is not working because of the two branches above which are currently like this :
I'm currently cleaning up my repo from old unused big files and random branches left hanging around. This has created some empty commits which I've been able to delete from git. However, I can't delete this empty merge commit. See attached image of my git tree. I have 2 branches other than main (branching off higher up in the git tree) called alex and pierre.
See attached image :
I've tried this git rebase command :
git rebase --onto 129294f9cda35e8c5861122668351519318fccec de782492dfa62b19d35a8c703a241a793475ff08
It gave me weird conflicts on the .gitignore file. After resolving that the rebase still failed and I was left with a very weird looking git tree with my pierre branch all on it's own. I had to run git rebase --abort
. I think the rebase is not working because of the two branches above which are currently like this :
1 Answer
Reset to default 1git filter-repo --prune-degenerate=always
should be able to get rid of such commits. (The tool is available from GitHub or pip.)
Alternatively, the manual approach:
- Edit the raw commit object with
git replace --edit <merge_commit>
, removing the unnecessary 2nd parent. This will create a 'replace' ref that makes Git tools pretend they see a different object than there is. - Verify that tools now see the wanted commit history.
- Bake for ~10 minutes using
git filter-branch
(without any specific options). This will rewrite the commit history to fully incorporate the "replacement" object.
本文标签: gitHow to delete empty merge commitStack Overflow
版权声明:本文标题:git - How to delete empty merge commit - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744864356a2629258.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论