Java 签出与文件冲突。我该如何进行?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/25737269/
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-08-11 01:02:32  来源:igfitidea点击:

Checkout conflict with files. How do I proceed?

javaeclipseegitjgitvcs-checkout

提问by CodyBugstein

I just pulled some changes from a remote repository holding my teams project.

我刚刚从保存我的团队项目的远程存储库中提取了一些更改。

This is the message I received on pull:

这是我在拉取时收到的消息:

Checkout Conflict

结账冲突

Apparently, one of my partners made changed to the same file as me.

显然,我的一位合作伙伴与我更改了相同的文件。

How do I proceed from here? The message is very vague. Was there an error? Do I have to undo what I did? Does he have to?

我如何从这里开始?该消息非常模糊。有错误吗?我必须撤销我所做的吗?他必须吗?

回答by Breandán Dalton

You must manually resolve the conflictby incorporating your partner's change into your code and committing the manually merged file.

您必须通过将合作伙伴的更改合并到您的代码中并提交手动合并的文件来手动解决冲突

Alternatively, if your changes aren't too complex, you may revert (throw away) your changes to that file, update your code to pick up your partner's changes, and then redo your work.

或者,如果您的更改不太复杂,您可以恢复(丢弃)对该文件的更改,更新您的代码以获取您合作伙伴的更改,然后重做您的工作。

See this

看到这个

回答by chrisinmtown

Do you have uncommitted changes in the file that's in your working copy? Or is your working copy clean? The EGit documentation guides you thru the latter scenario.

您的工作副本中的文件是否有未提交的更改?或者你的工作副本干净吗?EGit 文档将指导您完成后一种情况。

In my experience, the error dialog posted by @lmray is what EGit shows when a local working copy has uncommitted changes. EGit wishes to merge in information from the remote but I'm told it will not modify a dirty working copy. To proceed, you must first commit your changes locally, giving you a fallback point, then request merge again. The merge should then produce a merged file, hopefully without any conflicts.

根据我的经验,@lmray 发布的错误对话框是 EGit 在本地工作副本有未提交的更改时显示的内容。EGit 希望合并来自远程的信息,但我被告知它不会修改脏工作副本。要继续,您必须首先在本地提交更改,为您提供一个回退点,然后再次请求合并。然后合并应该产生一个合并的文件,希望没有任何冲突。

Thanks to @B. Dalton for trying to straighten me out - my dirty working copy file had uncommitted changes, and a local git wizard explained things.

感谢@B。Dalton 试图纠正我 - 我的脏工作副本文件有未提交的更改,并且本地 git 向导解释了一些事情。

Digression: this is a mental adjustment if you (like me) were used to working with SVN, which would happily pull remote changes into a dirty local working file. Not saying that was better, just that git works differently. I'm still struggling to convert my SVN-trained intuition over to suitable expectations for Git.

题外话:如果您(像我一样)习惯于使用 SVN,那么这是一种心理调整,SVN 很乐意将远程更改拉入脏的本地工作文件中。并不是说那更好,只是 git 的工作方式不同。我仍在努力将我经过 SVN 训练的直觉转换为对 Git 的合适期望。

回答by Pushkin

I faced this issue today and below solution works for me.

我今天遇到了这个问题,以下解决方案对我有用。

  1. Do a git stash. This will consolidate all your local and conflicting changes.
  2. Do a git pull now
  1. 做一个 git stash。这将整合所有本地和冲突的更改。
  2. 现在做一个 git pull