git and hardlink in linux

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?

  • Is it possible to securely delete a repository from Github
  • Changing capitalization of filenames in Git
  • git equivalent to `svn export` or github workaround
  • How to update my working Git branch from another branch (develop) ?
  • Using git, how to avoid rebase and push?
  • How to find out the contents of a git push
  • if so, how can I use git to manage these dotfiles?any suggestion

  • Checking out the branches of a git repository into sub folders?
  • Gitignore: add a file that is in an excluded folder
  • Cygwin/Git error cygheap base mismatch detected
  • Why does “git pull” get all branches from repository but “git pull origin master” doesn't?
  • git - revert update-index/ignored file so I can change branch?
  • How to keep a folder up-to-date with a git repo?
  • 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:

    • 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.

    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
    
    Git Baby is a git and github fan, let's start git clone.