【问题标题】:How do I blow away my attempt to resolve git conflicts我如何摆脱解决 git 冲突的尝试
【发布时间】:2013-01-04 13:19:27
【问题描述】:

我检查了“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

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

如何返回工作目录中的“production_branch”,以便部署一个简单的关键修复。

【问题讨论】:

    标签: git git-revert


    【解决方案1】:

    你可以使用

    git merge --abort
    

    中止您当前的合并操作并恢复到您开始合并之前的情况。详情请见git merge documentation

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

    【讨论】:

    • 谢谢!非常有帮助:)
    【解决方案2】:

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

    git reset --hard commitsha
    

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

    更新

    或在分支git reset --hard production_branch

    【讨论】:

    • 或者只是git reset --hard HEAD
    猜你喜欢
    • 1970-01-01
    • 2018-05-15
    • 1970-01-01
    • 2010-11-28
    • 1970-01-01
    • 2017-08-13
    • 2010-09-11
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多