如何解决"git stash apply"引起的"删除/修改"冲突

stu*_*kov 17 git

我最近做了一个git stash,然后在分支上做了一些工作并提交了它,并在尝试做一个时遇到了这些错误git stash apply:

CONFLICT (delete/modify): app/controllers/orders_controller.rb deleted in Updated upstream and modified in Stashed changes. Version Stashed changes of app/controllers/orders_controller.rb left in tree.
CONFLICT (content): Merge conflict in app/models/product.rb
Run Code Online (Sandbox Code Playgroud)

git status 显示以下内容:

 $ git status
# On branch develop
# Your branch is ahead of 'origin/develop' by 16 commits.
# Unmerged paths: 
#   (use "git reset HEAD <file>..." to unstage)
#   (use "git add/rm <file>..." as appropriate to mark resolution)
#
#   deleted by us:      app/controllers/orders_controller.rb
#   both modified:      app/models/product.rb
Run Code Online (Sandbox Code Playgroud)

标记为"删除/修改"的文件是我添加的新文件,之前尚未提交stash.
我想回到我之前所处的状态git stash- 有未提交的本地更改.你能建议如何实现这一目标吗?

谢谢.

raj*_*240 11

这对我有用。

做一个-

git mergetool
Run Code Online (Sandbox Code Playgroud)

然后你会被要求选择修改或删除的文件或中止,然后再做一次 -

git mergetool
Run Code Online (Sandbox Code Playgroud)

这将解决合并冲突,您可以隐藏您的更改。


GoZ*_*ner 8

你正在把藏匿处带到另一个州; 有一个额外提交的州.更糟糕的是,正如您所知,提交引入了合并冲突.

您有两种选择:

  1. pop存入最新提交并解决冲突
  2. 将存储弹出到先前的提交.

听起来像#2就是你想要做的.使用:

    git stash branch new_branch [<stash>]  # <stash> will be the last one if not provided.
Run Code Online (Sandbox Code Playgroud)

  • 所以在错误的分支上执行'git reset --hard',这将删除'stash apply'引入的所有本地更改(在工作目录中).然后你可以从你的问题中查看原始分支('develop')并按照我的建议应用存储. (3认同)
  • 那么如何做#1? (2认同)