开发者

How do you version your home? I would like some info about subrepos

开发者 https://www.devze.com 2023-01-27 20:01 出处:网络
I\'ve started to put some files in version control in mercurial. It started with .vim, and then with .bashrc, and now I realized a lot of other files could be versioned as well (such as .zshrc, .task

I've started to put some files in version control in mercurial. It started with .vim, and then with .bashrc, and now I realized a lot of other files could be versioned as well (such as .zshrc, .task directory created by taskwarrior, etc)

Fact is I would like to know which approachs are available and how people here in SO do it.

Versioning home is not a good idea since I would need to edit my .hgignore, and each time a new folder I don't want versioned is added I would need to edit .hgignore as well.

So I think of 2 approaches:

  • Create a "dotfiles" repo with everything inside it (vim, b开发者_运维技巧ash, screenrc), clone it in home and create symbolic links in home to them;
  • Create a "dotfiles" repo and a repo for each configuration (vim, bash, screenrc, cvsrc, etc). This "dotfiles" repo will just have the other repositories as submodules, but creation of symbolic links in home is still needed.

Do you think it's overkill to create a repository for each configuration in the second approach? Do you have another suggestions? I would like to use this approach on linux/mac. I use vim on windows as well, that's why I tought of making different repositories with submodules - in windows I would just clone the vim repo: the home repo would have vim as a submodule.

(I'm using a bitbucket private account. Is it possible to have submodules in there? And one more thing: is it possible to have git submodules inside a mercurial repository as submodules as well? How?)

Thanks!


Most folks who do this put something like this in their ~/.hgignore file:

.*

which automatically ignores everything. Then they just hg add the files they do want tracked -- hg add overrides ignore rules (unlike in CVS/svn).

One thing to beware of is that mercurial doesn't track file permissions (excepting the execute bit) so you have to be careful of things like .ssh/authorized_keys getting permissions other than the 600 it needs. Tools like etckeeper automate the permissions (and ownership) handling parts of this making hg (or git) suitable for use on not just ~ but also system things like /etc.


I would suggest making one repository, and hard linking all of your dotfiles there. This way, you will only be managing one repository, but you don't have to have a .hgignore with every file in your home directory. I do this with Dropbox instead of Mercurial, and it works quite well.


Although all answers were great, I decided by my own solution.

I'm going to create two repositories: vim and home (I use vim in different operating systems, *nixes and windows, so it's worth having separate repositories for that). Vim is going to be a subrepo in home.

Home is going to be a dotfiles folder, having a bash script that symlinks everything, so I can clone my repo and just run the script.

0

精彩评论

暂无评论...
验证码 换一张
取 消