GitHub每个分支的代码所有者

huangapple go评论56阅读模式
英文:

github codeowners for each branch

问题

GitHub表示可以为不同的分支分配不同的代码所有者。
但是如何操作呢?
是否有一种方法可以在合并时避免不同分支上的不同文件之间的冲突?

请告诉我如何操作。

文档链接: https://docs.github.com/en/enterprise-cloud@latest/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-code-owners#codeowners-file-location

每个CODEOWNERS文件为存储库中的单个分支分配代码所有者。因此,您可以为不同的分支分配不同的代码所有者,例如将默认分支上的代码分配给@octo-org/codeowners-team,将gh-pages分支上的GitHub Pages站点的代码分配给@octocat。

英文:

Github says I can assign different code owners for different branch.
but how?
Is there any way for having different file for different branch without any conflict on merging??

please let me know how I can do it.

https://docs.github.com/en/enterprise-cloud@latest/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-code-owners#codeowners-file-location
> Each CODEOWNERS file assigns the code owners for a single branch in the repository. Thus, you can assign different code owners for different branches, such as @octo-org/codeowners-team for a code base on the default branch and @octocat for a GitHub Pages site on the gh-pages branch.

答案1

得分: 1

以下是翻译好的部分:

  1. Github says I can assign different code owners for different branch.
    GitHub表示我可以为不同的分支分配不同的代码所有者。

  2. but how?
    但是如何做呢?

  3. Is there any way for having different file for different branch without any conflict on merging??
    是否有任何方法可以在合并时使不同分支具有不同的文件,而不会发生冲突?

  4. Well, no. But you can configure your local repository to work around the conflicts.
    嗯,没有。但是你可以配置你的本地仓库以解决这些冲突。

  5. First, you can use builtin merge driver "ours"; see https://stackoverflow.com/a/59503455/7976758 found in https://stackoverflow.com/search?q=%5Bgit%5D+exclude+file+merge
    首先,你可以使用内置的合并驱动程序"ours";参见 https://stackoverflow.com/a/59503455/7976758,可以在 https://stackoverflow.com/search?q=%5Bgit%5D+exclude+file+merge 找到。

  6. echo .github/CODEOWNERS merge=ours >> .gitattributes
    echo .github/CODEOWNERS merge=ours >> .gitattributes

  7. git config merge.ours.driver true
    git config merge.ours.driver true

  8. This doesn't completely exclude the file from merge but lower the frequency of conflicts. If you want to completely exclude it and always update it manually you can do
    这并不完全排除文件的合并,但可以降低冲突的频率。如果你想完全排除它并始终手动更新它,你可以这样做

  9. git checkout HEAD .github/CODEOWNERS after merge. You can try to automate this in a post-merge hook. Something like
    合并后使用 git checkout HEAD .github/CODEOWNERS。你可以尝试在post-merge钩子中自动化这个过程,类似于:

echo '#! /bin/sh
git checkout HEAD .github/CODEOWNERS
' > .git/hooks/post-merge
chmod u+x .git/hooks/post-merge

希望这些翻译对你有所帮助。

英文:

> Github says I can assign different code owners for different branch.<br>
> but how?

Exactly that — by having different files in different branches.

> Is there any way for having different file for different branch without any conflict on merging??

Well, no. But you can configure your local repository to work around the conflicts.

First, you can use builtin merge driver "ours"; see https://stackoverflow.com/a/59503455/7976758 found in https://stackoverflow.com/search?q=%5Bgit%5D+exclude+file+merge

echo .github/CODEOWNERS merge=ours &gt;&gt; .gitattributes
git config merge.ours.driver true

This doesn't completely exclude the file from merge but lower the frequency of conflicts. If you want to completely exclude it and always update it manually you can do

git checkout HEAD .github/CODEOWNERS

after merge. You can try to automate this in a post-merge hook. Something like

echo &#39;#! /bin/sh
git checkout HEAD .github/CODEOWNERS
&#39; &gt; .git/hooks/post-merge
chmod u+x .git/hooks/post-merge

huangapple
  • 本文由 发表于 2023年2月8日 08:39:30
  • 转载请务必保留本文链接:https://go.coder-hub.com/75380368.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定