Git and Dropbox together

Git is a source code management tool and heavily used to open source software developers particulary with services such as These managed source code locations are called repositories. Source code repository is a powerful place to find history of source code modifications or to download the source code instantly.

However sometimes you might want to have a repository that is only available for you. For example, as a backup repository.

So what can you do? You can have a backup copy inside your local computer. You can configure git to set any folder on your local machine to act a git repository.

However you wouldn’t be able to have the project on another machine unless you keep a copy with you always.

This is where Dropbox comes into play. All you have to do is to create a your repository folder inside the Dropbox folder. So now we need two folders, one that represent our project repository, and the other is project folder.

If you are using two operating systems on the same machine, it is better if you place these folders in the same drive. Why is that? Let’s suppose you are using a Linux OS and Windows OS. Both of these platforms support different driver types and problems would arise as Linux represent a driver differently compared to Windows.

So to overcome this problem, we use a single driver and use relevant path instead of absolute path when adding the remote repository location.

So lets suppose your Dropbox folder is located inside D: drive or mounted as disk on Linux. You project folder is located on some place inside this drive.

Dropbox folder: D://Dropbox
Project Folder:D://someplace/projects/my_project

Open up the console and go to d drive. Use Git Bash console for this.

cd someplace/projects/my_project
git init
git add .
commit -m “first commit”

Then go back to dropbox folder
cd ../../Dropbox

create a folder for projects, if there is none
mkdir projects

Initialize a git project repository for your project
git init –bare my_project

Go back to initial project folder
cd ../../someplace/projects/my_project

Add the repository location
git remote add origin ../../Dropbox/projects/my_project

git push -u origin master

Now you can use the local repository like normal. Wait till the repository folder is completely downloaded on another machine, before you are going to clone.

This is not really suitable for teams if they are going to push at the same time, because at that moment Dropbox application will start uploading the modified files inside the Dropbox folder. When the same file is uploaded to simultaneously from different machines, Dropbox makes duplicate files.

0 0 vote
Article Rating

By Sinaru Gunawardena

Sinaru is a software developer at work and a painter in free time. He enjoys writing tech notes on his personal website. He currently lives in Dublin, Ireland.

Notify of
Inline Feedbacks
View all comments