无法硬链接gitconfig文件 [英] Can't Hard Link the gitconfig File

查看:116
本文介绍了无法硬链接gitconfig文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图创建一个git存储库来存储我所有的dotfiles和配置文件。我的想法是简单地创建硬链接到我关心的所有文件,并将这些链接存储在自己的目录中,以便将其转化为存储库。



我已经尽管用我的〜/ .gitconfig文件碰到了一些障碍。似乎每当我运行'git config'命令时,我创建的链接都不再指向正确的位置,例如存储库中的文件不再正确更新。



以下是使用shell和交互式ruby确定文件链接状态的示例。

 #创建链接
$ ln .gitconfig .conf_files / gitconfig#创建链接

#文件实际上链接
[1] pry(main)> File.identical?('.gitconfig','.conf_files / gitconfig')
=> true

#通过运行'git config'命令来更新gitconfig文件
$ git config --global alias.last'log -1 HEAD'

#这些文件不再链接。
[2] pry(main)> File.identical?('.gitconfig','.conf_files / gitconfig')
=>假

我认为这与git编写.gitconfig文件的方式有关。有人知道为什么会发生这种情况,或者有任何创造性的解决方法吗?

解决方案

试试Eli Barzilay的解决方案 http://www.xxeo.com/archives/ 2010/02/16 / dotfiles-in-git-finally-did-it.html


最终找到了一个解决方案,它将两者中最好的一个放在一起:将repo
放在子目录中,而不是符号链接,为
core.worktree添加一个配置选项作为您的主目录。现在,当你在你家的
目录中时,你不在git仓库中(所以第一个问题已经消失),而你的
不需要处理脆弱的符号链接,就像第二种情况一样。你还有
有排除你不想版本化的路径的麻烦(例如,
是.git / info / exclude技巧中的*),但这并不新鲜。 p>


I am attempting to create a git repository to store all of my dotfiles and config files. My idea was to simply create hard links to all of the files I cared about and store those links in their own directory that I could turn into a repository.

I've hit a bit of a snag though with my ~/.gitconfig file. It seems that whenever I run the 'git config' command the link that I created no longer points to the right location e.g. the file in the repository no longer updates properly.

Here is an example using the shell and interactive ruby to determine the files linked state.

# Create the link
$ ln .gitconfig .conf_files/gitconfig  # Create the link

# The files are in fact linked
[1] pry(main)> File.identical?('.gitconfig', '.conf_files/gitconfig')
=> true

# Update the gitconfig file by running a 'git config' command
$ git config --global alias.last 'log -1 HEAD'

# The files are no longer linked.
[2] pry(main)> File.identical?('.gitconfig', '.conf_files/gitconfig')
=> false

I assume this has something to do with the way that git is writing the .gitconfig file. Does anyone know why this would happen, or have any creative ideas for a workaround?

解决方案

Try Eli Barzilay's solution in his comment at http://www.xxeo.com/archives/2010/02/16/dotfiles-in-git-finally-did-it.html:

So I’ve finally found a solution that takes the best of both: put the repo in a subdirectory, and instead of symlinks, add a configuration option for "core.worktree" to be your home directory. Now when you’re in your home directory you’re not in a git repo (so the first problem is gone), and you don’t need to deal with fragile symlinks as in the second case. You still have the minor hassle of excluding paths that you don’t want versioned (eg, the "*" in ".git/info/exclude" trick), but that’s not new.

这篇关于无法硬链接gitconfig文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆