Sharing several git repos between computers
At any given time I’m working on several papers in LaTeX. I like to keep my papers in git repos in order to use branching, be able to revert, etc. etc. Part of the time I work on my computer at my office, and part of the time at home.
I have a directory containing several git repos (each for one paper, in its own subdirectory). I’d like a good way to manage all of these repos across the computers. Of course I could simply clone every repo on both computers and push/pull across a server, but then I have to clone every single repo by hand, create new directories on both computers every time I start a new project, etc.
Instead I could keep all the projects in the same repo, but I want to have separate branches going for each, and I need to be able to share certain projects with certain coauthors. My current approach is to simply rsync everything when I go home at night, but then it’s a nuisance if I forget to sync before I leave.
Question: what is the “right” way to handle this situation?
(other relevant info: I am running Linux and prefer a command-line approach. No Dropbox allowed.)
2 Solutions collect form web for “Sharing several git repos between computers”
You have at least three range of options:
This is the simplest way, because it only needs Git and SSH. You could have a central repository on one of your machines using ssh (which is one of the protocols git supports) and point all your “slave” repositories to this one. Check this link for more information.
This approach does not require Internet connection, only ssh access to the machines, Git does the rest of the magic.
b) Publish repositories via HTTP on your own machine
You can host your repository via HTTP on one of your Linux machines using gitorious. The bad part is that you have to set up the configuration. Once it’s done, you are all set!!
This approach does not require Internet connection assuming your machines are on the same or a reachable network.
c) Hosting via Bitbucket or Github
Assuming that your papers will be private repositories, I recommend using Bitbucket (as it is free for private repositories). Github is even better (IMHO), but for private repositories it’s not free.
Both Github and Bitbucket work via a HTTP or SSH connection to those websites, so they require having an Internet connection.
Keeping repos synchronised:
One of the ways to do this is using hooks. This approach cab be combined with one of a) or b). Basically, after each push, you can run a script to sync the rest of the repositories, via rsync or any other approach.
If your question mainly about easy management of mutable set of repositories in common location, you can think about Git submodules or subtrees:
Parent directory (which holds all real repos) become empty “super-repository” with repositories as submodules|subtrees (but still part of superrepo for fetch|push|clone), adding|removing node is just a question of single command|editing relevant config-file