Using GIT with Google Drive – a Tutorial

While there are many public repositories out there, they all come with a caveat; do you really want to host your private code with something you don’t know will be there tomorrow.

So far I’ve been having a private repository at a host, but that’s not uber practical either since backup is non-existing and you eventually will feel the need / lust for re-installing that system.

So then, it’s really great to see that there’s a (quite) simple way of using Google Drive as the code repository for Git. The setup isn’t even that hard but there are some places you can stumble. This tutorial of setting up Git for Google Drive is for Windows, though the procedure for *nix based systems is almost the same except for the folder structure.

So, here we go:

Start by downloading Git (at

Get a google account at and then download google drive for windows (you’ll find the link at when you are logged on with your google account

If everything went OK, you now have a Google Drive folder in your “user” folder under your windows user folder like so (where your username shows up instead of JoeUser as in this example) C:\Users\JoeUser\Google Drive

Now, create a folder in your Google Drive folder called “git”. You want this folder as git produces a lot of files and you may want other stuff on your google drive besides your code repository.

mkdir \Users\JoeUser\Google Drive\git

Obviously, this can also be done from Windows Explorer (new folder).
Now, go to your code folder on your windows machine and start the Git Bash window (looks like a CMD-window). Most often, you can just right-mouse-button click and press “Git Bash”

In the git bash command window, CD yourself to your project folder (or whatever folder you want to have git control over).

cd /C/MyProjects/Project1

(note that in order to reach another volume than C: you can just do CD /D/MyProjects/Project1 etc)

Now, in the projects folder, perform the following git commands

git init
git add .
git commit -m "first commit"

Now we go to Google Drive and create a bare git repo (note that the backslash between Google and Drive should be exactly there)

cd /C/Users/JoeUser/Google\ Drive/git
git init --bare project1.git

This sets up the remote part of our repository. Now we just need to connect the two like so.

cd /C/MyProjects/Project1
git remote add origin /C/Users/JoeUser/Google\ Drive/git/project1.git
git push -u origin master

Well, that’s it really. Now you have setup so that when you next time do a “git push” you will do so to Google Drive in the cloud and your code is safe.

To checkout this project from another machine, you simply make sure you have google drive on that machine and type

cd /the_location_I_want_to_checkout_the_repo
git clone /C/Users/JoeUser/Google\ Drive/git/project1.git

There is one major caveat that you should know about (not a show stopper, but important to have control over). On some Windows machines, Google Drive can have trouble to synch all the Git files in one go. There’s a simple solution, you just shut down Google Drive and restart it again. It then re-synchs and the remaining files get synched. It’s important to not forget to check this after each git push since otherwise you can mess up the git project files on Google Drive and you’d be left with a mess.

By continuing to use the site, you agree to the use of cookies. more information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.