我可以在 git 存储库中拥有一个文件,每个人都可以获取它,但每个人都会忽略它吗?

发布于 2025-01-13 20:14:46 字数 274 浏览 3 评论 0原文

我在存储库中有两个文件(它们包含在克隆和更新中),因此每个人都可以访问这些脚本。但我希望它们的更改不会被跟踪,并且它们永远不会自动提交(由任何人)。

如果我将它们放入 gitignore 文件中并将它们从存储库中删除(并使用 --cached 保留本地副本),那么其他人将无法再访问它们。

我是否忽略了使用 gitignore 函数来实现此目的的简单方法?

编辑:这些文件在开始时使用三个参数绘制脚本(在本地编辑和运行)。大多数时候,脚本中的其他内容都没有改变(如果改变了,那么就值得提交)。

I have two files I would like in the repository (they are included in clone and update), so everybody has access to these scripts. But I want that changes in them are not tracked and they are never automatically committed (by anyone).

If I put them in the gitignore file and remove them from the repository (and keep a local copy with --cached), then they are not accessible to others anymore.

Am I overlooking a simple way to use the gitignore function to achieve this?

edit: These files are plotting scripts with three parameters in the beginning (which are edited and run locally). Most of the time nothing else in the script changes (and if it did it would be worthy of a commit).

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

末蓝 2025-01-20 20:14:46

通过 Git 分发文件的唯一方法是将它们添加到存储库,因此将跟踪文件的更改。如果您删除文件并提交删除,Git 将跟踪删除并分发给从您​​拉取的每个人。

我的解决方案是跟踪模板文件,将该文件复制到忽略的路径,根据需要进行编辑,然后从该忽略的路径加载。

The only way to distribute files via Git is to add them to the repository, and thus changes to the files will be tracked. And if you delete the files and commit the deletion, the deletion will be tracked by Git and distributed to everyone who pulls from you.

My goto solution is to track a template file, copy this file to an ignored path, edit as needed, and load from this ignored path.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文