Git的恢复提交有一些其他的提交取决于它 [英] Git revert a commit that has some other commit depending on it

查看:227
本文介绍了Git的恢复提交有一些其他的提交取决于它的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

让我们说我们有承诺 A B B 取决于 A 的修改。
我们希望恢复 A ,那将是成功?另外,如果通过'A'加了线不再present会发生什么?

Let's say we have commit A and B, and B depends on A's modification. We want to revert A, will that be successful? Also, what would happen if a line added by 'A' is no longer present?

推荐答案

混帐将报告该还原导致冲突。 git的状态将显示未合并的路径。

git will report that the revert resulted in a conflict. git status will show the unmerged paths.

您可以解决冲突像其他。

编辑与例如:

$ mkdir foo
$ cd foo
$ git init
$ echo "this is a line in a file" > blah
$ echo "this is a second line in a file" >> blah
$ echo "this is a third line in a file" >> blah
$ git add blah
$ git commit -m "first commit"
# edit the second line in blah
$ git commit -am "second commit"
# remove the second line from blah
$ git commit -am "third commit"
$ git revert HEAD^ #revert the second commit
error: could not revert 4862546... another change
hint: after resolving the conflicts, mark the corrected paths
hint: with 'git add <paths>' or 'git rm <paths>'
hint: and commit the result with 'git commit'
$ git status
# On branch master
# Unmerged paths:
#   (use "git reset HEAD <file>..." to unstage)
#   (use "git add <file>..." to mark resolution)
#
#   both modified:      blah
#
no changes added to commit (use "git add" and/or "git commit -a")

在该第一提交添加的文件和情况下,第二修改的文件,GIT中的状态将显示这一点:

In the case that the first commit added the file and the second modified that file, git status will show this:

$ git status
# On branch master
# Unmerged paths:
#   (use "git reset HEAD <file>..." to unstage)
#   (use "git add/rm <file>..." as appropriate to mark resolution)
#
#   deleted by them:    blah
#

这篇关于Git的恢复提交有一些其他的提交取决于它的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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