博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
git 还原合并_如何在Git中还原合并
阅读量:2517 次
发布时间:2019-05-11

本文共 2714 字,大约阅读时间需要 9 分钟。

git 还原合并

I a branch, say b1, from another branch, say b2. Both b1 and b2 have some commits.

我从另一个分支b2 了一个分支b1。 b1和b2都有一些提交。

Say,

说,

b1: c1 --->  c2 ---> c3b2: c1 --->  c4 ---> c5

Now, if I merge b2 to b1 and there is no conflicts, b1’s history includes b2’s commits (c4, c5).

现在,如果我将b2合并到b1并且没有冲突,则b1的历史记录将包括b2的提交(c4,c5)。

How to this merge in Git?

如何在Git中此合并?

You can revert/undo the merge (a successful one as in the question) by

您可以通过以下方式还原/撤消合并(在问题中是成功的合并):

$ git reset --hard ORIG_HEAD

But be aware that running git reset --hard ORIG_HEAD will let you go back to where you were, but it will discard your local changes, which you do not want. git reset --merge keeps your local changes.

但是请注意,运行git reset --hard ORIG_HEAD将使您返回到原来的位置,但是它将丢弃您不需要的本地更改。 git reset --merge保留您的本地更改。

Two more examples from the :

另外两个示例:

Undo a merge or pull       $ git pull                         (1)       Auto-merging nitfol       CONFLICT (content): Merge conflict in nitfol       Automatic merge failed; fix conflicts and then commit the result.       $ git reset --hard                 (2)       $ git pull . topic/branch          (3)       Updating from 41223... to 13134...       Fast-forward       $ git reset --hard ORIG_HEAD       (4)   1. Try to from the upstream resulted in a lot of conflicts; you were not ready to spend a lot of time merging right now, so you decide to do that later.   2. "pull" has not made merge commit, so "git reset --hard" which is a synonym for "git reset --hard HEAD" clears the mess from the index file and the working tree.   3. Merge a topic branch into the current branch, which resulted in a fast-forward.   4. But you decided that the topic branch is not ready for public consumption yet. "pull" or "merge" always leaves the original tip of the current branch in ORIG_HEAD, so   resetting hard to it brings your index file and the working tree back to that state, and resets the tip of the branch to that commit.Undo a merge or pull inside a dirty working tree       $ git pull                         (1)       Auto-merging nitfol       Merge made by recursive.        nitfol                |   20 +++++----        ...       $ git reset --merge ORIG_HEAD      (2)   1. Even if you may have local modifications in your working tree, you can safely say "git pull" when you know that the change in the other branch does not overlap with them.   2. After inspecting the result of the merge, you may find that the change in the other branch is unsatisfactory. Running "git reset --hard ORIG_HEAD" will let you go back to   where you were, but it will discard your local changes, which you do not want. "git reset --merge" keeps your local changes.
Answered by anonymous.
匿名回答。

翻译自:

git 还原合并

转载地址:http://ipowd.baihongyu.com/

你可能感兴趣的文章
Uploadify 上传文件插件详解
查看>>
游戏开发设计模式之子类沙盒模式(unity3d 示例实现)
查看>>
时间复杂度与空间复杂度
查看>>
Ajax 是什么?Ajax 的交互模型?同步和异步的区别?如何解决跨域问题
查看>>
Session 起航 登录会话和注销请求 重定向和转发
查看>>
毕设问题小记——Struts2如何将父类属性序列化为JSON格式
查看>>
有效投标不足三家不应是重新招标的必要条件
查看>>
标准分页
查看>>
3dContactPointAnnotationTool开发日志(二四)
查看>>
C语言运算符优先级
查看>>
javascript 之this指针-11
查看>>
完成登录与注册页面的前端
查看>>
hihocoder 1643 Puzzle Game(北京icpc2017 现场赛)
查看>>
vim 简单理解三种模式 粗暴入门
查看>>
django模板层之静态文件引入优化
查看>>
转载使用命令wsimport构建WebService客户端
查看>>
java实现23种设计模式之模版方法模式
查看>>
小程序·云开发实战 - 校园约拍小程序
查看>>
闲话函数式变成与OOP
查看>>
Linux-正则表达式与三剑客
查看>>