git - Delete commit which is merged into main branch -


how delete purple commit , "merge branch..." commit. try using "git rebase -i head~x" not work.

enter image description here

you can kind of magic git fast-export (after made backup of working copy): run git fast-export --no-data --all --full-tree > all_commits in working copy. open file all_commits in text editor, , search "initial commit". environment around should this:

commit refs/heads/master mark :110 author foo bar <foobar@example.org> 1462192582 +0100 committer foo bar <foobar@example.org> 1462192582 +0100 data 14 initial commit deleteall m 100644 b346ed4d2db0c8110fe3104bd155a413b878527c some/file  commit refs/heads/master mark :111 author foo bar <foobar@example.org> 1462192582 +0100 committer foo bar <foobar@example.org> 1462192582 +0100 data 21 merge branch 'master' :109 merge :110 deleteall m 100644 b346ed4d2db0c8110fe3104bd155a413b878527c some/file m 100644 4d9af842ccf23b883b234f5ae93d71f11fa285de some/other_file  commit refs/heads/master mark :112 author foo bar <foobar@example.org> 1462192582 +0100 committer foo bar <foobar@example.org> 1462192582 +0100 data 14 did stuff :111 deleteall m 100644 b346ed4d2db0c8110fe3104bd155a413b878527c some/file m 100644 d6a0ad80d11b9d376c23d17300ce95d724d050e7 some/other_file 

you cut out commit, removing commit block , adjustment of references (mark places reference commit identify later, , from or merge identify parents of commit):

commit refs/heads/master mark :111 author foo bar <foobar@example.org> 1462192582 +0100 committer foo bar <foobar@example.org> 1462192582 +0100 data 21 merge branch 'master' :109 deleteall m 100644 b346ed4d2db0c8110fe3104bd155a413b878527c some/file m 100644 4d9af842ccf23b883b234f5ae93d71f11fa285de some/other_file  commit refs/heads/master mark :112 author foo bar <foobar@example.org> 1462192582 +0100 committer foo bar <foobar@example.org> 1462192582 +0100 data 14 did stuff :111 deleteall m 100644 b346ed4d2db0c8110fe3104bd155a413b878527c some/file m 100644 d6a0ad80d11b9d376c23d17300ce95d724d050e7 some/other_file 

than import changed stream git fast-import --force < all_commits. after operation, offending commit gone.

when went wrong, can recover original commits git fast-import --force < all_commits.backup, not bad idea create backup before operation.


Comments

Popular posts from this blog

loops - Spock: How to use test data with @Stepwise -

amazon web services - S3 Pre-signed POST validate file type? -