Git remove duplicates

After I played with the remote, I ended up doubled all my commits. For example. instead

C3107
..
C3
C2
C1

I got

C3107
C3107
..
C3
C3
C2
C2
C1
C1

where double commits have the same name but different hashes. The problem is that I noticed this too late, and I did not add a good bunch of commits on top of it.

Is there a way to remove duplicate commits and not lose the ones I added?

PS: If this helps, I have a copy of the repository before my experiments with the remote.

Thank you very much in advance.

. , : repo R1, R2. , R1, R2 , github. , git filter-branch --index-filter 'git rm --cached --ignore-unmatch filename', git , . R2, , R1, . R1.

+4
3

.

0

, grepping , , , "". , , 3000 !

() , . , , , git.

+6

git rebase -i #commit id, #

. , , .

pick 07520cd Caught file exists issue. # this is last commit
fixup 3b71b9f Added README.            # fixup will squash the commit

# Rebase b041966..3b71b9f onto b041966
#
# Commands:
#  p, pick = use commit
#  r, reword = use commit, but edit the commit message
#  e, edit = use commit, but stop for amending
#  s, squash = use commit, but meld into previous commit
#  f, fixup = like "squash", but discard this commit log message
#  x, exec = run command (the rest of the line) using shell
#
# These lines can be re-ordered; they are executed from top to bottom.
#
# If you remove a line here THAT COMMIT WILL BE LOST.
#
# However, if you remove everything, the rebase will be aborted.
#
# Note that empty commits are commented out

git koan (koan 8), git rebase -i.

https://github.com/jbremson/git_koans ( )

~

+4

Source: https://habr.com/ru/post/1524607/


All Articles