如何防止在git上连续提交特定文件? [英] How to prevent successive commit on specific file on git?

查看:111
本文介绍了如何防止在git上连续提交特定文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些配置文件要使用默认参数在GIT上提交。
用户可以获取这些文件,并可以在本地副本上修改它们,但它们不得提交/推送。



如何获得类似的结果?文件gitignore不适合我的需要,因为文件必须是第一次提交

解决方案

您可以使用git的承担不变功能?如果设置了这个,git总是假设相关文件没有被修改。这意味着git status,git commit等会跳过这个文件。请注意,用户仍然可以将新版本的文件推送到您的远程仓库,但需要做一些额外的工作才能做到这一点。 这里是一个问题,其中假设不变的用法被更彻底地讨论过了。

p>

I have some configuration files to commit on GIT with default parameters. Users can pull these files and can modify them on their local copy but they must not commit/push.

How can I achieve a similar result? the file gitignore doesn't fit my need because file must be commit only the first time

解决方案

Could you use git's "assume unchanged" function? If this is set, git always assumes that the file in question has not been modified. This means that git status, git commit etc. will skip the file. Please note that the user can still push a new version of the file into your remote repo but it will take some extra work to do that.

Here's a question where the usage of "assume unchanged" was discussed more thoroughly.

这篇关于如何防止在git上连续提交特定文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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