Thread (6 messages) flat view 6 messages, 3 authors, 2016-06-15

Re: Undo a commit that is already pushed to central server and merged to several branches

From: Ramkumar Ramachandra <hidden>
Date: 2016-06-15 22:52:34

Hi Matthias,

Matthias Fechner wrote:
[...]
I continued to work then on different branches and merged the bad master
branch to all my other branches.
[...]

What I would like to do is move this bogus commit into a different branch
and remove all changes from this bogus commit from every branch.
If I understand correctly, each of your branches looks like*:

o  <--- HEAD of branch; merge commit referencing bogus commit
| \
o  \   <--- This is where you want to move the HEAD to
|   \
o    o  <-- Bogus commit from master branch
|
o
|
o  <-- Branch born

Assuming that you actually want to rewrite the history, the situation
calls for a git-reset(1).  Just "git reset --hard HEAD~1" on each of
your branches (Caution: first understand what it does!) and you'll
rewind the HEAD to "undo" the bad merge.  After that you can just "git
push +foo:foo" to overwrite the foo branch on your server.  If you
don't want to rewrite anything and simply commit the inverse of the
bad commit, see git-revert(1).

* If you're having difficulty understanding the diagram, please read:
http://eagain.net/articles/git-for-computer-scientists/

Cheers.

-- Ram
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help