我如何打击解决 git 冲突的尝试

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/14439443/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 08:03:19  来源:igfitidea点击:

How do I blow away my attempt to resolve git conflicts

gitgit-revert

提问by Charles Magid

I checked out 'production_branch' then did a merge of 'master_branch for_production_branch' there were massive conflicts. 'production_branch' has been deployed to production. But the conflicts require a more experienced eye. I need to get a critical patch (I will do it by hand) onto the production branch 'production_branch' so I can deploy.

我检查了 'production_branch' 然后合并了 'master_branch for_production_branch' 有大量的冲突。“production_branch”已部署到生产环境。但冲突需要更有经验的眼光。我需要在生产分支“production_branch”上获得一个关键补丁(我将手动完成),以便我可以部署。

git co 'production_branch'  # => 
lib/tasks/foobar.rake: needs merge
vendor/plugins/acts_as_syncable/lib/active_record/whatever.rb: needs merge
error: you need to resolve your current index first

and

git co 'master_branch for_production_branch'
lib/tasks/foobar.rake: needs merge
vendor/plugins/acts_as_syncable/lib/active_record/whatever.rb: needs merge
error: you need to resolve your current index first

How can I get back to 'production_branch' in my working directory so I can deploy a simple critical fix.

我怎样才能回到我的工作目录中的“production_branch”,以便我可以部署一个简单的关键修复程序。

回答by Veger

You can use

您可以使用

git merge --abort

to abort your current merge action and revert to the situation before your started the merge. See git merge documentationfor more details.

中止当前的合并操作并恢复到开始合并之前的情况。有关更多详细信息,请参阅git merge 文档

Note that it will throw away any changes your made, but I suppose this is not a problem in your current situation...

请注意,它会丢弃您所做的任何更改,但我想这在您目前的情况下不是问题......

回答by ch4nd4n

To blow away all the changes and set to prior to merge

吹走所有更改并设置为在合并之前

git reset --hard commitsha

Here commitsha is the sha id of git commits. You can use gitkor git logto check state of your branch and figure out commit_sha

这里的 commitsha 是 git commits 的 sha id。您可以使用gitkgit log检查分支的状态并找出commit_sha

Update

更新

or on branch git reset --hard production_branch

或在分支上 git reset --hard production_branch