7.8 节Git 工具-高级合并-其他类型的合并-我们的或他们的偏好-最后一段对 ours 解释模糊

Open
#476 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
35/100
Issue type
Documentation
Clarity
Clearly specified
Activity status
Stale
Tech stack
git
Domain
documentation

Research direction

Start with section 7.8, “Git 工具-高级合并-其他类型的合并-我们的或他们的偏好,” and compare the final explanation of the ours strategy with issue 426 and the linked Stack Overflow discussions. Update the Chinese paragraph so the skipped commit, later bug fixes, and merge direction are unambiguous, then verify the edited documentation renders correctly.

Written by the indexing model from the issue text.

Description

现在的版本:

当再次合并时从本质上欺骗 Git 认为那个分支已经合并过经常是很有用的。 例如,假设你有一个分叉的 release 分支并且在上面做了一些你想要在未来某个时候合并回 master 的工作。 与此同时 master 分支上的某些 bugfix 需要向后移植回 release 分支。 你可以合并 bugfix 分支进入 release 分支同时也 merge -s ours 合并进入你的 master 分支 (即使那个修复已经在那儿了)这样当你之后再次合并 release 分支时,就不会有来自 bugfix 的冲突。

修改后容易理解的版本:

如果在合并操作中要跳过某个提交, 并在稍后要继续进行合并操作, 诱使Git认为分支已经合并通常是有帮助的. 假设你分出了一个名为release的分支, 在该分支上完成了一些工作, 希望之后将release分支合并回master分支. 在此之间, 在master分支上进行的一些bug修复工作需要向后移植到release分支, 你可以将master分支合并入release分支. 随后, 如果master分支有一个提交A的内容不想合并到release分支, 但是在这个提交A之后的还未出现的bug修复预计会继续合并到release分支, 这时可以使用merge -s ours将master合并入release分支.

参考资料:

https://github.com/progit/progit2/issues/426
英文版也有很多人不理解在讲什么

stackoverflow 上对 ours 使用场景解释比较全面的回答
https://stackoverflow.com/questions/5077688/why-would-one-use-git-merge-s-ours
https://stackoverflow.com/questions/727994/git-skipping-specific-commits-when-merging/729723

Dominant language
CSS
Stars
1.6k
Forks
360
PR merge metrics
No merged PRs in 30d

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from progit/progit2-zh

All issues in progit/progit2-zh

Similar issues

More Documentation issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.