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?

  • Git push new local branch to remote, without having to specify name
  • Embed Git bash in PyCharm as external tool and work with it in PyCharm window
  • Error encountered while cloning the remote repository with VS 2015 Update 3 (TFS 2015 Update 3)
  • How is the Git config evaluated when commit-ing?
  • Git commit returns “nothing to commit”
  • My pull request has been merged, what to do next?
  • if so, how can I use git to manage these dotfiles?any suggestion

  • “no address associated with name” error when cloning's repo under Windows using ssh
  • Trouble on running the command 'git remote' in order to deploy a Ruby on Rails application
  • Merging a branch of a branch after first branch is squashed when merged to master
  • git encrypt/decrypt remote repository files while push/pull
  • Use GIT fork / branches
  • What remote does “git push” push to when there is no origin?
  • 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/ln -sf /path/to/repo/zshrc $HOME/.zshrc
    Git Baby is a git and github fan, let's start git clone.