Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

git and hardlink in linux

Tags:

git

linux

zsh

I have a git repo test, and a file (zsh config file), and

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

like image 646
Li Song Avatar asked Feb 22 '23 00:02

Li Song


2 Answers

You can't make¹ hard links outside a git repository. You have several choices:

  • Make ~/.zshrc a symbolic link to my-home-git-checkout/zshrc.
  • 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.

like image 163
Gilles 'SO- stop being evil' Avatar answered Mar 06 '23 01:03

Gilles 'SO- stop being evil'


Git always assumes that he is a only owner of a file inode. So git checkout just breaks all hard links.

like image 43
Alexandr Priymak Avatar answered Mar 06 '23 02:03

Alexandr Priymak