Git reset vs revert

0 Shares
0
0
0

Today I realized I woke up with the wrong feet when I noticed that I made wrong commits last night that I had to revert/reset today.  So, the question was if I should need to reset or revert?  

I could have taken an easy path but I want to take this opportunity to truly understand the difference between git revert and reset so here is my blog post/cheat sheet for future use:

image

Reverting in my own words:  It makes a “new” commit which includes the changes to fix the past (“wrong”) commits.   To keep in mind:  You will have the history of the wrong commits in your tree 

Resetting in my own words:  It goes back to the last “correct” commit, erasing all the “wrong commits”. To keep in mind:  You will not have the history of the wrong commits in your tree

What did I learn? 

Context: I am working with a team who constantly pull and push information or I want to keep a history of all my commits including those “wrong” commits.

Problem:  I made a wrong commits( were not caught immediately) which erase or created any conflict for the project 

Solution:  Use REVERT

image

If I want to use RESET, I will not be able to have a history of those wrong commits such as the image below show after I reset my commits:

image

 

0 Shares
Leave a Reply

Your email address will not be published. Required fields are marked *

You May Also Like