What is the difference between git reset and git revert?

Hi, I am new to git and I don’t understand what is the main difference between git reset and git revert . Does git revert return merge merge?

+6
source share
2 answers

As far as I know, they do completely different things.

git revert , designed to return the effects of a previous commit. For instance,

 A <- B <- C ^ HEAD 

If I found the B that I committed earlier, this is wrong, and I want to "undo" change it, git-revert -ing B will result in:

 A <- B <- C <- B' ^ HEAD 

for which B' changes the change made in B.

git reset more straight forward, it just sets HEAD for a specific commit,

 A <- B <- C ^ HEAD 

git-reset -ting to B will give you

 A <- B <- C ^ HEAD 
+24
source

Git reset -> move the tip of the branch to another commit. This can be used to remove commits from the current branch. He moves the branch back, fixing. Git Revert -> undo commits, creating a new commit. This is a safe way to roll back changes since it has no chance to rewrite the commit history.

0
source

Source: https://habr.com/ru/post/978439/


All Articles