version control - Delete a pushed old git commit -


we working on single branch 20 developers. yesterday accidentally messed auto merge commit.

he had pull taken 24 hours(span-1) before committing. after committing , taking pull accidentally reverted files shown in auto merge commit believing shouldn't committed had not changed files. after committed auto merge , pushed it. after 24 hours(span-2) of push recognized issue.

now problem is, in span-1 have around 25 commits 10 developers , similar in span-2. changes on same/different files same/different developers.

we tried cherry picking asks conflict resolution not possible in our case many developers involved.

is there way solve problem. want delete merge commit. if required can delete actual commit done developer between span-1 , span-2. having these changes in history not problem. want clean repository.

note: question here doesn't address specific problem. general question on deleting git commits. not interested in deleting/rewriting history. want rolled changes due bad merge available on remote repository without having resolve merge conflicts

is there way solve problem.
want delete merge commit


reset

  # reset branch given commit   git reset head <sha-1>    # push branch -f flag = rebase   #    # dangerous, rebase.    # developers have re-clone project   git push -f origin <branch> 

revert (create commit reverse patch)

this way don't rewrite history.

on other hand, if you've published work, don't want reset branch, since that's rewriting history.

in case, indeed revert commits.

# create x separate revert commits  # (undo original commit changes) # if revert merge have supply parent number `-m` git revert <sha1> <sha1> <sha1> ...  # takes ranges. revert last 2 commits: git revert head~x..head~y  # reverting merge commit git revert -m 1 <merge_commit_sha> 

the git-revert manpage covers lot of in description.
useful link this git-scm.com blog post discussing git-revert.

if decide didn't want revert after all, can revert revert (as described here) or reset before revert (see previous section).


git filter-branch

lets rewrite git revision history rewriting branches mentioned in , applying custom filters on each revision.

those filters can modify each tree (e.g. removing file or running perl rewrite on files) or information each commit. otherwise, information (including original commit times or merge information) preserved.


Comments

Popular posts from this blog

ruby - Trying to change last to "x"s to 23 -

jquery - Clone last and append item to closest class -

c - Unrecognised emulation mode: elf_i386 on MinGW32 -