git reset和git revert有什么区别? [英] What is the difference between git reset and git revert?

查看:128
本文介绍了git reset和git revert有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是git的新手,我不明白git resetgit 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆