Git删除重复的提交 [英] Git remove duplicate commits
问题描述
在玩过遥控器之后,我的所有提交都翻了一番。例如。而不是
C3107
..
C3
C2
C1
我得到了
C3107
C3107
..
C3
C3
C2
C2
C1
C1
其中doubled提交具有相同的名称,但具有不同的哈希值。问题是我注意到它太晚了,而不是我在它上面增加了一大堆提交。
有没有办法删除重复的提交而不是松散的提交我添加了吗?
PS:如果在我使用遥控器进行实验之前,我有一个存储库的副本。
更新你们很多人在这里问的是如何结束这样的:我有一个回购R1然后我创建了另一个R2。在我的R1本地副本中,我将R1的起源更改为R2,并试图推送,但一些大文件被github拒绝。所以我做了 git filter-branch --index-filter'git rm --cached --ignore-unmatch filename'
这让git认为存储库是不同的。然后我全部推到R2做了一些提交,并决定再次切换回R1改变原点并推送。然后我给R1增加了一些提交。
最后,我决定支持cherrypicking。 $ b
After some playing with remotes I ended up with all my commits being doubled. E.g. instead of
C3107
..
C3
C2
C1
I got
C3107
C3107
..
C3
C3
C2
C2
C1
C1
where doubled commits has same names but different hashes. The problem is I noticed it too late and not I added a good bunch of commits on top of it.
Is there a way to remove duplicate commits and not not loose ones I added over?
P.S.: If it will help I have a copy of a repository before my experiments with remotes.
Thanks a lot in advance.
UPDATE As many of you asked here is how ended up like this: I have a repo R1 then I created another one R2. At my local copy which was up to date with R1 I changed origins to R2 and tried to push but some large files were rejected by github. So I did git filter-branch --index-filter 'git rm --cached --ignore-unmatch filename'
which made git think repositories are different. Then I pushed all to R2 made some commits and decided to switch back to R1 changed origin again and pushed. Then I added some more commits to R1.
An the end I decided in favour of cherrypicking.
这篇关于Git删除重复的提交的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!