Sharing multiple git repos between computers

At any given moment I am working on multiple documents in LaTeX. I like to keep my documents in git repos so that I can branch out, be able to go back, etc. Etc. I work partly on my computer in my office and part of the time at home.

I have a directory containing multiple git repos (each for one paper, in its own subdirectory). I need a good way to manage all these repositories on computers. Of course, I could just clone each repo on both computers and push / pull through the server, but then I have to clone each repo manually, create new directories on both computers every time I start a new project, etc.

Instead, I could keep all projects in the same repo, but I want to have separate branches for each, and I need to be able to share some projects with some contributors. My current approach is to just rsync everything when I go home at night, but then it's a nuisance if I forget to sync before leaving.

The question is, what's the β€œright” way to handle this situation?

(Other relevant information: I'm running Linux and prefer the command line approach. Dropbox allowed.)

+3


source to share


2 answers


You have at least three options:

a) SSH

This is the easiest way because it only needs Git and SSH . You can have a central repository on one of your machines using ssh (which is one of the git protocols) and point all your "slave" repositories to that one. Please see this link for more information .

This approach does not require an internet connection, only ssh access to the machines, git does the rest of the magic.

b) Publish repositories over HTTP on your machine

You can host your repository over HTTP on one of your Linux machines using gitorious . The bad part is you need to tweak the configuration. Once that's done, you're all set!



This approach does not require an Internet connection if your computers are on the same network or reachable network.

c) Hosting via Bitbucket or Github

Assuming your documents will be private repositories, I recommend using Bitbucket (since it's free for private repositories). Github is even better (IMHO), but for private repos, it's not free .

Both Github and Bitbucket work over HTTP or SSH connections to these websites, so they require an internet connection.

Keeping synchronized repositories:

One way to do this is with hooks . This approach should be combined with either a) or b). Basically, after each click, you can run a script to sync the rest of the repos using rsync or any other approach.

+3


source


If your question is mainly about easily managing a mutable set of repositories in a common place, you can think of Git submodules or subtrees:



The parent directory (containing all the real repositories ) becomes an empty "superrepositor" with the repositories as submodules | subtrees (but still part of the super repo for fetching | push | clone), adding | deleting a node is just a matter of a single command | editing the corresponding config file

+1


source







All Articles