views:

64

answers:

2
+2  Q: 

Git and hard links

Since git does not recognize symbolic links that point to outside of the repository.

is there any problem using hard links ?

Git could break them ? Can point me to detailed information ?

+1  A: 

From this msysgit issue

Junction points are not symbolic links; therefore, symbolic links are simply unsupported in msysGit.

Also, hard links were never tracked by Git.

The issue were Windows-oriented (since it is about msysgit) and debate about the potential support of symlink.
But the comment about hard link concerns Git in general.

VonC
+3  A: 

The 'tree' object, representing directories in Git, stores file name and (subset of) permissions. It doesn't store inode number (or other kind of file id). Therefore hard links cannot be represented in git, at least not without third party tools such as metastore or git-cache-meta (and I am not sure if it is possible even with those tools).

Git tries to not touch files that it doesn't need to update, but you have to take into account that git doesn't try to preserve hardlinks, so they can be broken by git.


About symbolic links pointing outside repository: git has no problems with them and should preserve contents of symbolic links... but utility of such links is dubious to me, as whether those symlinks would be broken or not depends on the filesystem layout outside git repository, and not under control of git.

Jakub Narębski
Symlinks to paths outside of the repo can be useful. I've used them in webapps to point to database or media files not tracked by the repo. That way, the web app's config file can point to a static path, but the actual location of that path can vary between local development and server environments.
mipadi
@mipadi: BTW. Modern gitweb has special case for displaying symlinks leading after normalization outside repository.
Jakub Narębski