忽略内容更改文件后,将其推入GIT存储库后
我有一个文件用户。每次运行测试套件时,此CSV文件都会更新。
我不希望该文件在我的本地计算机中进行修改 每次运行测试套件时。在这种情况下,我认为我可以使用 命令
git update-index - assume-hindanged [< file> ...]]
参考:我可以'git Commits'a文件并忽略其内容更改吗?
- 现在,假设另一个开发人员拉了我推动的所有更改。 当测试套件在他的计算机上运行时,相同的CSV不应显示为修改,并且该文件仍应在他的机器中。
我假设将文件添加到.gitignore中 。已经跟踪了。
关于如何实现这一目标有什么想法吗?
I have a file users.csv
which is pushed to the repository. This csv file gets updated every time the test suite is run.
I don't want the file to be shown as modified in my local machine
every time the test suite is run. In that case i assume i can use the
commandgit update-index --assume-unchanged [<file> ...]
Ref: Can I 'git commit' a file and ignore its content changes?
- Now, assume that another developer pulled all the changes that i pushed. When the test suite is run on his machine, the same csv should not show as modified and the file should be still there in his machine.
I assume adding the file in .gitignore will not help since the file is already tracked.
Any idea on how to achieve this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
理想情况下,测试套件应:
user.csv
touser.csv.test
(中的
user.csv.test
。存储库。
Ideally, the test suite should:
users.csv
touser.csv.test
(withuser.csv.test
in the.gitignore
, so left as a private file)user.csv.test
That way, you don't have to manage
update-index
on each developer repositories.GIT特别没有提供忽略对跟踪文件的更改的方法。这是在git Faq 中彻底回答:
您是正确的,
.gitignore
对已经跟踪的文件没有影响。有几种方法可以避免在这里遇到问题。首先是将临时目录(或
test/tmp
)进行测试套件输入和输出以避免这是一个问题。这就是GIT所做的,其他几个项目也是如此。您也可以将文件
users.csv
忽略并将真实文件移至其他位置,然后在使用前将其复制到位。然后,如果测试套件对其进行了修改,则在开发系统上不会有问题。Git specifically doesn't offer a way to ignore changes to tracked files. This is thoroughly answered in the Git FAQ:
You are correct that
.gitignore
has no effect on files that are already tracked.There are a couple ways you can avoid having a problem here. The first is to use a temporary directory (or an ignored directory like
test/tmp
) for your test suite input and output to avoid this being a problem. This is what Git does and several other projects do as well.You could also leave the file
users.csv
ignored and move the real file to a different location, and then copy it into place before use. Then, if the test suite modifies it, it won't be a problem on development systems.