Git:如何创建不同的未合并状态?

发布于 2024-09-05 09:55:09 字数 160 浏览 2 评论 0原文

什么时候会出现不同的 git status 未合并状态,例如由我们添加由他们添加都已删除

我尝试通过执行合并来重现后者,其中文件已在当前分支和合并源分支中删除,但我无法创建此状态。

When do different git status unmerged states occur, like added by us, added by them or both deleted?

I've tried to reproduce the latter by performing a merge where a file has been deleted in the current and merged-from branch, but I was not able to create this status.

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

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

发布评论

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

评论(1

深陷 2024-09-12 09:55:09

您可以通过在每个分支中以不同的方式重命名文件来获取所有三个文件。

git init
touch foo
git add foo
git commit -m 'initial commit'
git checkout -b tmp
git mv foo X
git commit -m 'rename to X'
git checkout -
git mv foo Y
git commit -m 'rename to Y'
git merge tmp

现在您已拥有所有三个状态。

$ git status
# On branch master
# Unmerged paths:
#   (use "git add/rm ..." as appropriate to mark resolution)
#
#       added by them:      X
#       added by us:        Y
#       both deleted:       foo
#
no changes added to commit (use "git add" and/or "git commit -a")

You can get all three by renaming a file differently in each branch.

git init
touch foo
git add foo
git commit -m 'initial commit'
git checkout -b tmp
git mv foo X
git commit -m 'rename to X'
git checkout -
git mv foo Y
git commit -m 'rename to Y'
git merge tmp

Now you have all three states.

$ git status
# On branch master
# Unmerged paths:
#   (use "git add/rm ..." as appropriate to mark resolution)
#
#       added by them:      X
#       added by us:        Y
#       both deleted:       foo
#
no changes added to commit (use "git add" and/or "git commit -a")
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文