git and hardlink in linux
ln ~/.zshrc test/zshrc
then I changed .zshrc file,the zshrc file in git repo didn’t change,is that git cannot deal with hardlink?
if so, how can I use git to manage these dotfiles?any suggestion
3 Solutions collect form web for “git and hardlink in linux”
You can’t make¹ hard links outside a git repository. You have several choices:
~/.zshrca symbolic link to
- Keep a git checkout in your home directory.
- Copy the file from your git checkout to your home directory, perhaps automatically upon a commit or checkout.
¹ Yeah, ok, quibble: you can’t keep.
Git always assumes that he is a only owner of a file inode.
So git checkout just breaks all hard links.
Try adding the following script into
/path/to/repo/.git/hooks/post-checkout (this file must be executable):
#!/bin/sh /bin/ln -sf /path/to/repo/zshrc $HOME/.zshrc