github中的pull请求时如何忽略或排除文件 [英] How to ignore or exclude a file when pull request in github

查看:97
本文介绍了github中的pull请求时如何忽略或排除文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有4个分支机构:1-dev,2-qa,3-staging,4-master.我们要更新并在1-dev的CODEOWNERS文件中添加一些人员,并将保留2-qa到4-master的CODEOWNER文件中.由于1-dev有4个审阅者,而2-qa到4-master则有2个审阅者.

We have 4 branches, 1-dev, 2-qa, 3-staging, 4-master. We want to update and add some people in CODEOWNERS file in 1-dev, and 2-qa to 4-master's CODEOWNER's file will be retain. Since there are 4 reviewers for 1-dev and 2 reviewers for 2-qa to 4-master.

我尝试添加包含以下内容的.gitattributes文件:

I tried adding .gitattributes file that contains:

 CODEOWNERS -diff
 CODEOWNERS linguist-generated=true

因此,我尝试将其推送到所有分支中,并更新1-dev中的CODEOWNER文件.但是,当从1-dev合并到2-qa时,仍会修改CODEOWNERS文件.拉取请求时如何排除或忽略此文件?谢谢.

So I tried to push this in all branches, and update the CODEOWNER file in 1-dev. But when merging from 1-dev to 2-qa, the CODEOWNERS file is still modified. How do I exclude or ignore this file when pull requesting? Thanks.

推荐答案

您想要的是一种避免合并某些文件的方法,而GitHub不支持此功能,因为通常情况下,Git不支持此功能.这个问题已经在Git列表上问过了,一般的答案是,尽管使用自定义合并驱动程序可以实现,但这不是一个好主意.

What you're asking for is a way to avoid merging certain files, and GitHub doesn't support this because, in general, Git doesn't support this. This question has been asked on the Git list, and the general answer is that while this is possible with a custom merge driver, it's not a good idea.

由于GitHub不使用自定义合并驱动程序,因此您需要创建一个自定义合并驱动程序,并使用 .gitattributes 中的 merge 属性进行设置,然后用bot进行所有手动合并,而不是让GitHub进行合并.如果您确实愿意,可以这样做,但是如上所述,Git开发人员不推荐这样做.

Since GitHub doesn't use custom merge drivers, you'd need to both create a custom merge driver and set it using the merge attribute in .gitattributes and then do all manual merges with a bot instead of letting GitHub do the merges. That would allow you to do it if you really want to, but, as mentioned above, the Git developers don't recommend it.

这篇关于github中的pull请求时如何忽略或排除文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆