英文:
github codeowners for each branch
问题
GitHub表示可以为不同的分支分配不同的代码所有者。
但是如何操作呢?
是否有一种方法可以在合并时避免不同分支上的不同文件之间的冲突?
请告诉我如何操作。
每个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
以下是翻译好的部分:
-
Github says I can assign different code owners for different branch.
GitHub表示我可以为不同的分支分配不同的代码所有者。 -
but how?
但是如何做呢? -
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
首先,你可以使用内置的合并驱动程序"ours";参见 https://stackoverflow.com/a/59503455/7976758,可以在 https://stackoverflow.com/search?q=%5Bgit%5D+exclude+file+merge 找到。 -
echo .github/CODEOWNERS merge=ours >> .gitattributes
echo .github/CODEOWNERS merge=ours >> .gitattributes -
git config merge.ours.driver true
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
合并后使用 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 >> .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 '#! /bin/sh
git checkout HEAD .github/CODEOWNERS
' > .git/hooks/post-merge
chmod u+x .git/hooks/post-merge
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论