So, assume I have a git repository on an iDisk, mounted to my mac a /Volumes/garyjlittle. I also have a dropbox account mounted to /Dropbox.
I have a directory called ~/scripts on several machines (home and work) that I keep synchronized and version contolled using git.
Now, I want to move a git repository called “scripts” from iDisk to Dropbox.
Here’s what I do. I have a subdir called ‘git’ on my Dropbox drive, and within there I have a bunch of ‘bare’ repositories – because I always make edits in ~/scripts. The directory /Dropbox/git/scripts.git is just there to be a shared resource to push/pull from.
Make the directory hierarchy in Dropbox.
lovebox:[~] $ mkdir /Dropbox/git
lovebox:[~] $ mkdir /Dropbox/git/scripts.git
Change directory to the Dropbox script directory we just created.
lovebox:[~] $ cd /Dropbox/git/scripts.git
Now inititalize that directory as a git bare repository.
lovebox:[/Dropbox/git/scripts.git] $ git init --shared --bare
Now go to the iDisk directory which currently holds the bare repository
lovebox:[~] $ cd /Volumes/garyjlittle/scripts
And push over the repository to the new Dropbox location.
lovebox:[/Volumes/garyjlittle/scripts] $ git push --mirror /Dropbox/git/scripts.git/
Counting objects: 49, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (49/49), done.
Writing objects: 100% (49/49), 21.52 KiB, done.
Total 49 (delta 18), reused 0 (delta 0)
Unpacking objects: 100% (49/49), done.
To /Dropbox/git/scripts.git/
* [new branch] master -> master
Now we have to tell each remote location that the shared repository has changed. It’s easiest to just rename the old directory from ~/scripts to ~/old.scripts. And then do a git clone from the new Dropbox git location.
lovebox:[~] $ mv scripts/ old.scripts
lovebox:[~] $ git clone /Dropbox/git/scripts.git/ scripts
Initialized empty Git repository in /Users/gjl/scripts/.git/
lovebox:[~] $ cd scripts
You might notice (as I did) that there are fewer scripts in the new ~/scripts directory. That’s probably because not all of the scripts really were under git control. This could be a good time for housekeeping. Add in the scripts that you really want to keep under git version control, and get rid of the crufty old one-time stuff that inevitably builds up over time.