Nathan Ridley
Nathan Ridley

Reputation: 34396

How do I stop git from committing unchanged files?

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?

Upvotes: 2

Views: 2849

Answers (2)

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.

Upvotes: 6

kubi
kubi

Reputation: 49354

I'm guessing, but I bet that the line endings are different between your working directory and your commits. This answer should give you what you need to fix it.

Trying to fix line-endings with git filter-branch, but having no luck

Upvotes: 0

Related Questions