DEV Community

Discussion on: Different basic ways to undo commits on git

Collapse
 
jessekphillips profile image
Jesse Phillips

I like keeping a clean history a sometime that makes for merge conflicts when rebaseing.

I had an older which had changes I wanted gone. The commits later all belonged in the one commit. I could have just manually reverted. Instead, I go back with interactive rebase, edit the commit using amend to pull out the changes.

Since I don't want later merge conflict I commit these edits I don't want. I let the rebase finish. Then revert the commit I don't want.

Now I reset the branch softly all the back to the changes I don't want. I use ament to adjust the commit and message.

I know, lots of steps, but know the tools I apply stages that create a fairly streamlined edit where I can work to the end state I want and end up with a clean history. If the revert had conflicts, I would be working at the end state goal rather then conflicts within the rebase actions.

Collapse
 
ronalddpinho profile image
Ronaldd Pinho

Oh cool, of course. Keep a clean commit history is important. The deeper the knowledge of the tool, the more options you have to deal with these situations.

For example, I think when there are many branches, other situations that I didn't mention here arise. I rarely use rebase, only in well special cases, I think it is a higher level than what I wanted to show.
But is a cool command :D

Collapse
 
jessekphillips profile image
Jesse Phillips

I think it was important your article didn't go into rebase.

I just know that I used to create a poor man's rebase interactive and so happy to have found it.