1

I have a linux hard link (ln) pointing to a file in git. Anyone does know what happens if I update the file in git? Do I have to make to hard link again?

nacho
  • 5,280
  • 2
  • 25
  • 34
  • nope - it's just an alias for doing cd /path/to/file, not a temp data holder so changes shouldn't affect the link. If you're worried, you can test it - create a test.txt file, link it, then edit and see what happens – treyBake May 24 '17 at 13:54
  • no worries :) hope it helps – treyBake May 24 '17 at 14:26

1 Answers1

3

When the update done by git includes removal of the file, which could easily happen, the connection between file in git and the hard link outside of the repository would cease to exist.

In other words, using hardlinks with git is not a good idea. Also note that when you use harlink within git repository, git would complain about it.

marbu
  • 1,939
  • 2
  • 16
  • 30
  • Why would git complain about hard links? All my files are hard links. – Håken Lid May 24 '17 at 16:08
  • `git grep st_nlink` in the Git source to Git reveals only one test for `st_nlink > 1`, in `builtin/worktree.c`, where it is checking whether a worktree should be pruned. That implies that Git won't *complain*. You are correct that such links will be *severed*, though. – torek May 24 '17 at 18:39