Creating a GIT repository in Windows for cloud storage

One of the cool uses for cloud storage (such as Dropbox, SkyDrive or Google Drive) is as a git source code repository for your pet projects. Here's how to get started it in Windows.
But first, a couple of assumptions:

  • You have in your first machine a "Projects/Sandbox" folder with an existing project (e.g. a Visual Studio solution) and a "Dropbox" folder synched with the cloud; on the second machine a "Projects2" without any code and " Dropbox2" folder synched with the cloud. "dropbox" is the name of the remote repository.
  • You've previously added you git "bin" directory to your PATH environment variable.
  • You have Powershell installed (it's available for Windows XP or later). And yes, you could use the "classic" command prompt, but it's not as cool :) Really, if you're not familiar it's a good time to start using it.
So, launch Powershell and do the following:

# creating the remote repository
cd "C:\Dropbox\repositories"
git init --bare sandbox.git

# creating the local repository and first commit
cd "C:\Projects\Sandbox"
git init .
git remote add gdrive "C:\Dropbox\repositories\sandbox.git"
git add .
git commit -m "Initial commit"
git push dropbox master

# on a second machine, getting the repository
cd "C:\Projects2"
git clone -o gdrive "C:\Dropbox\repositories\sandbox.git"

Since I'm no expert on git, feel free to drop any comment about it Also, these instructions are adapted from this post, and mostly unchanged, as Powershell uses a UNIX-like syntax (actually, it uses aliases to do this, but you get the same result).

Edit (2012-09-05):
It seems that Google Drive has some issues syncing some files (e.g. HEAD and config) on Windows 7. The problem has been reported by other users. A workaround I found is to restart Google Drive when that happens, but that's not really interesting. I don't have these problems with Dropbox, though, so I recommend it instead. Haven't tested with SkyDrive yet.

No comments:

Post a Comment