如何阻止git提交未更改的文件? [英] How do I stop git from committing unchanged files?

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

问题描述

我的同事有一个问题,他的提交包含了存储库中的每个文件,而不仅仅是更改的文件。文件内容在字面上完全相同,但是我们的私人Github存储库中的变更集显示,删除了先前版本的所有行,并添加了所有新版本的行,即使实际上没有任何变化。这同样发生在二进制文件中,实际的文件从第一个版本到下一个版本都是相同的。



什么会导致这种情况,以及如何防止它? / p>

解决方案

由于Git通过散列它们的内容来识别文件,真正相同的文件将永远不会被存储两次。

您所看到的可能是存储库之间的行结束差异的症状。在不了解设置的情况下很难提供精确的建议,但阅读Git的配置选项 core.autocrlf core.safecrlf 可能会帮助你。


My coworker has an issue where his commits keep including every single file in the repository instead of just the changed ones. The file contents are literally identical, but the changeset in our private Github repository shows all of the previous version's lines removed and all of the "new" version's lines added, even though there was actually no change at all. This is also happening with binary files and again, the actual files are identical from the first version to the next.

What would cause this and how can it be prevented?

解决方案

Since Git identifies files by hashing their contents, truly identical files will never be stored twice.

What you are seeing may be a symptom of line ending differences between repositories. It’s hard to give precise advice without knowing more about your setup, but reading about Git’s config options core.autocrlf and core.safecrlf may probably help you.

这篇关于如何阻止git提交未更改的文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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