使用 egit 向/从中央 git 存储库推送/拉取后不会发生树冲突

发布于 2024-11-04 13:30:36 字数 693 浏览 3 评论 0原文

我们有 2 名开发人员使用 Egit。一个在 Windows 上工作,一个在 Linux 上工作

我们制定了如下协作策略:

  • 有一个中央(裸)存储库
  • 最初,每个开发人员都从中央存储库中签出并在本地工作。
  • 当两者需要同步工作时,我们从中央存储库拉取/推送到中央存储库。

我们按照我们的想法使用中央存储库,有了它,我们将来可以轻松地与团队中更多的开发人员协作。

一切工作正常,直到我们检测到当一个开发人员修改了另一个开发人员已移动到其他目录的文件时根本不存在冲突。步骤如下:

  • 一名开发人员将文件移动到另一个位置;将其提交到他的本地存储库;将其推送到中央存储库。
  • 另一个更改该(同一)文件的内容;将其提交到他的本地存储库。拉取中央存储库。

我们预计当第二个开发人员进行“拉取”时会出现冲突报告。但没有冲突。他的工作目录(以及他的本地存储库)中出现了 2 个文件:

  • 他修改的文件
  • 和第一个开发人员已移动到另一个目录的文件。

谁能告诉我们我们的错误是什么?

我们的工作方式是否违反了 git 的设计?

我们对 git 很陌生(很长时间以来都熟悉 CVCS)。遇到这个问题,我们非常担心,因为这意味着合并我们团队的工作将非常困难。我们相信我们一定做错了什么。感谢您为我们澄清。

We have 2 developers using EGit. One works on Windows, one works on Linux

And we set a policy for collaboration as following:

  • There is a central (bare) repository
  • Initially, each developer make a check out from the central repository and work locally.
  • When the two need to synchronise the work, we pull/push from/to the central repository.

We use the central repository as we think, with it, we can easily collaborate with more developers in the team in the future.

Everything works fine until we detect that there is no conflict at all when one developer modified a file that has been moved to other directory by the other. Here are the steps:

  • One developer, move a file to another location; commit it to his local repository; push it to the central repository.
  • The other one changes content of that (the same) file; commit it to his local repository. Pull the central repository.

We expect there is a conflict report when the second developer makes a "pull". But no conflict. And there are 2 files appear in his working directory (and in his local repository):

  • The one he modified
  • And the one that the first developer has moved to the other directory.

Could anyone tell us what is our mistake?

Is our way of working violates git's design?

We are new to git (being familiar with CVCS for a long time). Hitting this issue, we are very worry as that means it will be very difficult to merge the work of our team. We believe we must do something incorrectly. Thank you for clarify us.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

渔村楼浪 2024-11-11 13:30:36

我的猜测是你没有移动文件。当您移动文件时,它是删除和创建。当人们添加更改时,他们通常会忘记添加 -u 或 -A 选项,以不仅包括新文件、跟踪文件,还包括已删除的文件。

移动文件后,请确保暂存更改的删除端。如果有疑问,请使用 git log --stat 检查您是否从执行移动的提交中的旧位置删除了该文件。

希望这有帮助

My guess is that you didn't move the file. When you move a file it is a delete and create. When people add the change they usually forget to add the -u or -A option to include not just the new files, tracked files, but also the deleted files.

After the move of the file, make sure you stage the remove side of the change. If in doubt, check with git log --stat that you removed the file from the old location in the commit that does the move.

Hope this helps

小猫一只 2024-11-11 13:30:36

由于我使用的是 Egit,所以没有命令行。我确信在提交时我检查了已删除的文件和添加的文件。

但奇怪的是,我再次尝试通过:

  • 删除我的本地存储库(从存储库视图,右键单击,删除...)
  • 再次从中央存储库签出(克隆)
  • 并重做我上面提到的步骤

一切都按预期进行。我以前的本地存储库一定有问题,因为我可以创建一个 Team >拉。我需要先获取然后合并。再次检查后,如上所示。现在没事了。

As I am using Egit, there is no command line. And I am sure I checked both the deleted file and the added file when committing.

But strangely, I have tried again by:

  • Deleting my local repository (from repository view, right click, delete...)
  • Checkout again from central repo (clone)
  • And redo exactly steps that I mentioned above

Everything works as expected. There must be something problem with my previous local repository as I can make a Team > Pull. I need to make a Fetch then a Merge. After checking out again like above. It's OK now.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文