Git and hardlink on linux

I have a git repo test and file (zsh configuration file) and

ln ~/.zshrc test/zshrc 

then I changed the .zshrc file, the zshrc file in git repo did not change, is that git cannot work with hardlink?

if so, how can I use git to manage these points? any suggestion

+4
source share
3 answers

You cannot make 1 hard links outside the git repository. You have several options:

  • Make ~/.zshrc symlink to my-home-git-checkout/zshrc .
  • Store git checkout in your home directory.
  • Copy the file from your git check to your home directory, possibly automatically after commit or check.

ยน Yes, okay, pun: you can't resist.

+4
source

Git always assumes that it is the sole owner of the inode file. This way, the git check just breaks all the hard links.

+2
source

Try adding the following script to /path/to/repo/.git/hooks/post-checkout (this file must be executable):

 #!/bin/sh /bin/ln -sf /path/to/repo/zshrc $HOME/.zshrc 
+2
source

Source: https://habr.com/ru/post/1388418/


All Articles