简体   繁体   English

如何从存储中删除代码中的冲突警告

[英]How do I remove the conflict warnings in code from a stash

So I made some changes to some translation files in a directory (note that those changes aren't done manually, they are made by a command that updates the translation files based on a project's source code).所以我对目录中的一些翻译文件进行了一些更改(请注意,这些更改不是手动完成的,它们是通过根据项目的源代码更新翻译文件的命令进行的)。 I then stashed those changes and switched to another branch where I did a git stash pop and tried to commit those changes but got this error message:然后我隐藏了这些更改并切换到另一个分支,在那里我执行了git stash pop并尝试提交这些更改,但收到了以下错误消息:

error: Committing is not possible because you have unmerged files.错误:无法提交,因为您有未合并的文件。 I got the same output when I tried git merge当我尝试git merge时,我得到了相同的输出

So I did a git add , which worked.所以我做了一个git add ,它奏效了。 I then committed and pushed the changes.然后我提交并推送了更改。

Everything is fine except some of my files now have chunks of code framed by一切都很好,除了我的一些文件现在有大块的代码框架

<<<<<<< Updated upstream
    [code]
======= 
    [code]
>>>>>>> Stashed changes

The first [code] block seems to be the state of that part of the file before the git stash pop and the second one, the state after the git stash pop .第一个 [code] 块似乎是git stash pop之前的文件部分的状态,第二个是git stash pop之后的状态。

Those lines are an issue because my files have a xml format and aren't recognised as valid by a parser with those lines in them.这些行是一个问题,因为我的文件具有 xml 格式并且不被包含这些行的解析器识别为有效。

I have tried git merge and git pull but both give我试过git mergegit pull但都给

Already up-to-date.已经是最新的了。

as an output.作为输出。 How can I get safely git rid of those lines?我怎样才能安全地摆脱这些线?

So I did a git add, which worked.所以我做了一个 git add,它起作用了。 I then committed and pushed the changes.然后我提交并推送了更改。

This is where the error lies.这就是错误所在。 git stash pop produced merge conflicts, but you resolved those by just adding the files that needed merging, along with the conflict markers in the files. git stash pop产生了合并冲突,但您只需添加需要合并的文件以及文件中的冲突标记即可解决这些冲突。 Don't do that in the future - use ie git mergetool to fix conflicts.以后不要这样做 - 使用 ie git mergetool来修复冲突。

You state in the question that the files are generated automatically by a script, so easiest way to remedy the situation is probably to just regenerate them & commit.您在问题中声明文件是由脚本自动生成的,因此纠正这种情况的最简单方法可能是重新生成它们并提交。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM