[英]How to treat a local dotfile repository?
As many others, I want to have a git repository with my configuration files and also upload a backup of it to a hosting site. 和其他许多人一样,我想拥有一个包含我的配置文件的git存储库,并将其备份上传到托管站点。 My question is how to treat the dotfiles of the local repo.
我的问题是如何处理本地回购的dotfiles。
Let's say that I have my zshrc/bashrc in the dotfiles repo. 假设我在dotfiles repo中有我的zshrc / bashrc。 I can put the line 'source /path/to/local/repo/zshrc' to my ~/.zshrc file and everything's fine.
我可以将'source / path /到/ local / repo / zshrc'这一行放到我的〜/ .zshrc文件中,一切都很好。 Same thing with vimrc.
与vimrc相同。
But what about those dotfiles that doesn't support such a command? 但那些不支持这种命令的dotfiles呢? Should I have the same content in both ~/.conffile and /pathtolocalrepo/conffile and when I make a change to one of them update the other file?
我是否应该在〜/ .conffile和/ pathtolocalrepo / conffile中具有相同的内容,当我对其中一个进行更改时更新另一个文件? Or is there a smarter way?
或者有更聪明的方法吗?
What's the common practice? 常见的做法是什么?
Also where this local repository is located usually (on Linux)? 这个本地存储库通常位于何处(在Linux上)? I don't think home folder is the right place to put it (config files should be available to other users too), but which place suits it best?
我不认为主文件夹是正确的位置(配置文件应该也可供其他用户使用),但哪个地方最适合它?
Thanks in advance. 提前致谢。
You should probably use symbolic links. 您应该使用符号链接。
ln -s /path/to/repo/.zshrc ~/.zshrc
That means that when you try to access ~/.zshrc, this will instead look for the file /path/to/repo/.zshrc 这意味着当你尝试访问〜/ .zshrc时,这将代替文件/path/to/repo/.zshrc
For more infos on symbolic links, check this out : Symbolic Links 有关符号链接的更多信息,请查看: 符号链接
Note that you can perfectly create a "hard" link (without the -s option), only difference is that with hard links you cannot link directories nor link through filesystems (if /home and /path/to/repo are not on the same disk / partition) 请注意,您可以完美地创建“硬”链接(不带-s选项),唯一的区别是硬链接不能链接目录,也不能通过文件系统链接(如果/ home和/ path / to / repo不在同一个链接上)磁盘/分区)
Also where this local repository is located usually (on Linux)?
这个本地存储库通常位于何处(在Linux上)? I don't think home folder is the right place to put it (config files should be available to other users too), but which place suits it best?
我不认为主文件夹是正确的位置(配置文件应该也可供其他用户使用),但哪个地方最适合它?
I usually place all my git repositories in the ~/git folder but this really is a personal choice. 我通常将所有git存储库放在〜/ git文件夹中,但这确实是个人选择。
I do something similar, though for historical reasons I use CVS rather than Git. 我做了类似的事情,但由于历史原因,我使用CVS而不是Git。
I keep all my $HOME/.*
files (and $HOME/bin/*
scripts) in a CVS repository. 我将所有
$HOME/.*
文件(以及$HOME/bin/*
脚本)保存在CVS存储库中。 I then manually use update-home
and update-bin
scripts that I've written to copy the files into $HOME
or $HOME/bin
, respectively. 然后我手动使用我编写的
update-home
和update-bin
脚本将文件分别复制到$HOME
或$HOME/bin
。 It's a little bit wasteful of space (I suppose I could use symlinks instead), but not badly so -- and by copying rather than symlinking, I can experiment with files in the repository without affecting my home directory. 这有点浪费空间(我想我可以使用符号链接),但不是很糟糕 - 通过复制而不是符号链接,我可以在存储库中试验文件而不影响我的主目录。
The update-home
command, among other things, makes backup copies of any files that already exist, so that I don't clobber the .bashrc
file that was created when my account was set up. update-home
命令除了其他功能外,还会对已存在的任何文件进行备份,这样我就不会破坏设置帐户时创建的.bashrc
文件。 (And update-bin
edits #!
lines as needed, for example if I want to use a Perl executable other than /usr/bin/perl
.) (并且
update-bin
根据需要编辑#!
行,例如,如果我想使用除/usr/bin/perl
之外的Perl可执行文件。)
(My update-home
and update-bin
scripts aren't designed to be usable by others; they're full of hardwired names that apply only to me. Just copying the files manually would work about as well.) (我的
update-home
和update-bin
脚本不能被其他人使用;它们充满了仅适用于我的硬连线名称。只需手动复制文件也可以。)
A common practice is to backup your dotfiles in github. 通常的做法是在github中备份你的dotfiles。 There is a lot of work done for that practice.
这种做法有很多工作要做。
The idea is to clone that repository for each new computer you want to use. 我们的想法是为您要使用的每台新计算机克隆该存储库。
You can have a look to my personal repo to see how I implemented it. 您可以查看我的个人仓库以了解我是如何实现它的。 In my case I used a perl script called
dfm
to handle those symbolic links 在我的例子中,我使用了一个名为
dfm
的perl脚本来处理这些符号链接
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.