Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Putting home directory under source control (hg)

For a while I had just my code under source control, but I decided it would be cool to put things like my stuff in my .vim folder among other things in a repo. (I'm obviously not going to store everything in my repo, just various config files, my src directory, and maybe a few other things as well)

I was able to set up a repo fine, then push it to my server where I can access it from my other computers, but I can't clone it to my other computers. When I try to clone it it fails because the home directory isn't empty. Is there a way to do what I want here?

like image 557
Alex Avatar asked Feb 04 '11 17:02

Alex


2 Answers

Since the versioned files between my computers are the same, what I did was:

~$ hg clone ssh://myserver/hg/dotfiles mydotfiles
~$ mv mydotfiles/.hg .
~$ rm -rf mydotfiles

and that's it, now your home folder is under version control, but of course if your dot files are not identical between computers you will have to do something about it.

Since I only want to version some files and not everything under my home folder, I have this simple rule in ~/.hgignore

# This .hgignore is for the dotfiles repository only,
# the rest of my HG repositories use the file
# .hgignore_global as referenced by [ui]'s ignore setting.

syntax:glob
*

This way I don't get an ocean of files when I do hg status and only see those files that I have under version control that have been modified.

But since I want to see unversioned files when working within another hg repository, I have this in my ~/.hgrc file

[ui]
ignore=/home/gajon/.hgignore_global

And ~/.hgignore_global contains some filters for common transient files:

syntax: glob
*.pyc
*~
.*.swp
.svn*
*.svn*
*.fasl

syntax: regexp
^\.pc/
like image 142
Jorge Gajon Avatar answered Sep 28 '22 06:09

Jorge Gajon


Suppose you have proj1 and proj2. proj1 is a mercurial repo you want to clone to proj2, but proj2 already has files in it.

Try this:

hg clone proj1 proj3
mv proj3/.hg proj2
rmdir proj3
cd proj2
hg update -C -r tip
like image 23
Chris Marshall Avatar answered Sep 28 '22 04:09

Chris Marshall