如何阻止git提交未更改的文件?

编程入门 行业动态 更新时间:2024-10-09 19:23:19
本文介绍了如何阻止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提交未更改的文件?

本文发布于:2023-11-09 07:51:24,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1571785.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:文件   git

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!