Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I started using hard links instead of symbolic links to organize files ...

I've been doing this for pictures I take to categorize them as well as indicate which ones I want to print, etc.

I'm using git to backup my images and it appears that git thought they were new files as the repository grew about 1GB in size. Git does really well in detecting renames if I don't use git to rename the file, but does it also handle hard links?


share|improve this question
All normal files are hard links. Perhaps you meant "files with multiple hard links"? – Ignacio Vazquez-Abrams Apr 24 '11 at 21:23
Yes, that is what I meant. – Walter White Apr 25 '11 at 0:24
Correct me if I'm wrong, but doesn't git more track content? Why would it matter if the files have the same content, then - after all, they are technically the same file. – new123456 Apr 25 '11 at 0:57
For people who stumble across this - perhaps consider using Symbolic links instead? – CAD bloke Feb 23 '13 at 8:12
up vote 9 down vote accepted

Multiply linked tracked files will not cause Git’s object store to grow much since each link will be represented by the exact same blob object. Your working tree, however, might end up growing due to broken links.

Git does not track whether tracked, working tree files are hard links to the same file.

Git will leave multiply linked, tracked, working tree files alone if you do not ask it to do anything that would involve modifying the content at those pathnames or deleting the pathnames’ directory entries. But, if you were to (e.g.) checkout an old commit or branch and then switch back to your normal, most recent branch/commit, then Git will end up “breaking” the hard links (replacing the affected pathnames with new (but identical) files instead of recreating your multiply linked situation).

To recover your multiply linked status you could write a program to scan for identical files and relink them to any one of the files. Such a “relink” operation may be more complicated if all the links are not in the working tree itself or, at least, not in some easily identifiable “external” location (i.e. it will probably be difficult to recover the links if you are linking “random” files from all over your home directory into a “backup” repository and using Git to modify the working tree).

The idea has come up on the Git mailing list:

share|improve this answer
For debian-based linuxes, there is the hardlink tool ( which is able to do this relink operation. unfortunately, it's not very fast – Daniel Alder Nov 16 '15 at 15:12

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.