I've been using git for more than an year now, and I've settled on a repository organization that I like.
The foundations of this setup are:
- a GitHub account: the public face of my repositories. A free account is enough, and although I don't have private repositories at GitHub, I'm using the Micro plan, a mixture of kudos to the GitHub owners, and my preference for HTTPS-based access;
- gitosis: manages all my git repositories, both public and private;
x-git-update-to-latest-version: I re-compile git every day with the master branch, to help catch regressions.
For each project I have, I keep the repository on all my computers in the
~/work/ directory. Those repositories are synced between work computers (desktop at the office, and laptop everywhere else) using a Unison profile.
The use of Unison gives me the possibility of leaving work half done in the desktop, and finish up at home if I feel like it, without having to commit and push from one to the other.
On each repository, I have two main remotes configured.
origin remote points to my gitosis setup. You can use my gitosis install how-to for a painless setup. In addition, I add a
Host entry to my
~/.ssh/config like this:
Host git HostName hostname.of.server.with.gitosis User git
This allows me to use a simple
git:melo/repo.git as a remote URL. Short and to the point.
The second remote, named
github, is only created on public repositories, and points to my GitHub account.
Manually I add a third remote named
all. I copy the other two remotes
urls to it. This allows me to
git push all and have my changes pushed to both remotes with a single command. For example, for the
AnyEvent::Mojo project, I have this
[remote "origin"] url = git:perl/anyevent-mojo.git fetch = +refs/heads/*:refs/remotes/origin/* [remote "github"] url = [email protected]:melo/anyevent--mojo.git fetch = +refs/heads/*:refs/remotes/github/* [remote "all"] url = git:perl/anyevent-mojo.git url = [email protected]:melo/anyevent--mojo.git
This setup gives me peace of mind (all my code ends up on 4 different systems), and provides a pretty face (Github) for other to use.
Next step: create a script to make all this a one-step process.