Using Git with Dropbox
Posted on March 15, 2012 by Sol
Sometimes you want to keep a git repository private, at least temporary, without owning a server or a paid GitHub account. If you have a free Dropbox account you can host your private repo there.
Open a Terminal window if you are on Linux or Mac, on Windows just start a Bash window from your Git installation. Your Dropbox folder is created by default on HOME for Linux and Mac, or on MyDocuments in Windows.
Navigate to your Dropbox folder:
1 cd ~ 2 cd Dropbox
Once you are in ~/Dropbox you will want to create a bare git repo:
1 mkdir repo01 2 cd repo01 3 git --bare init
Now, you can use this folder as a private repository. Let’s try some tests:
1 cd ~ 2 mkdir local_repo01 3 cd local_repo01 4 git init 5 touch t1.txt t2.txt p.cpp 6 echo "add some text" > t1.txt
1 git add t1.txt t2.txt p.cpp 2 git commit -m 'test'
Add the “remote” repo (the one from Dropbox) as origin:
1 git remote add origin ~/Dropbox/repo01
Now, we can push the above files from the master branch to the remote origin:
1 git push origin master
If you want to simulate the workflow on a different machine clone repo01 change some files and save the changes:
1 cd ~ 2 git clone ~/Dropbox/repo01 test_clone 3 cd test_clone 4 ls > t2.txt 5 git commit t2.txt -m 'some changes' 6 git push origin master
You can go back to your original working folder and see the changes from the last step:
1 cd ~ 2 cd local_repo01 3 git pull origin master
If you want to learn more about using Git I would recommend Pro Git by S. Chacon:
comments powered by Disqus