git reset和git revert有什么区别? [英] What is the difference between git reset and git revert?
问题描述
我是git的新手,我不明白git reset
和git revert
之间的基本区别是什么. git revert
是否还原正在推送的合并?
Hi I am a newbie to git and I don't understand what is the basic difference between git reset
and git revert
. Does git revert
reverts the merge being pushed ?
推荐答案
据我所知,他们在做的事情完全不同.
As far as I know, they are doing totally different thing.
git revert
旨在恢复先前提交的效果.例如
git revert
aimed to revert effects of previous commit. For example,
A <- B <- C
^ HEAD
如果我发现之前提交的B是错误的,并且我想撤消"其更改,则git-revert
-ing B将导致:
If I found B I committed before is wrong, and I want to "undo" its change, git-revert
-ing B will cause:
A <- B <- C <- B'
^ HEAD
,其中B'
正在反转B中所做的更改.
for which B'
is reversing the change done in B.
git reset
更直接,它只是将HEAD设置为某个提交,
git reset
is more straight-forward, it is simply setting the HEAD to a certain commit,
A <- B <- C
^ HEAD
git-reset
-听B会给你
A <- B <- C
^ HEAD
这篇关于git reset和git revert有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!