Wednesday, July 15, 2009

Git Diff and Empty Files

I use git for local source control whenever possible.

If I am working with a system which does not have access to my repository, sometimes I use "git diff" to create patch files to update the remote site.

Today, I found a huge flaw in that strategy. If I have an empty file that was created on my local site, the "git diff" output does not include the file at all!

There are two ways around this. The first is to remember that the file needs to be created on the remote system and to "touch" the file. The second, and better way, is to never create completely empty files. Instead, create a file with a comment that it is intentionally left empty.

No comments:

Post a Comment