Saturday, June 11, 2011

Using dropbox as a git repo

I find using dropbox as a convenient way to access you code anywhere I want. The first step is to create a git repo in your dropbox directory:

mkdir myproject.git
cd myproject.git
git init --bare


For a new project, you can clone the git repo in dropbox

cd <where/you/want/your/project>
git clone <path/to/dropbox/..../myproject.git>
cd myproject
[hack.. hack.. hack]
git add <what you want to commit>
git commit [...]
git push


git push will push your changes to remote (the repo in dropbox). Now to continue your work elsewhere, you just have to let the dropbox do it sync and repeat steps above and push. This method can work even for an existing git project. You can create a bare git repo in dropbox, add the repo-in-dropbox as a new remote and push.

cd <where/you/your/project/is>
git remote add dropbox <path/to/dropbox/..../myproject.git>
git fetch dropbox
[hack.. hack.. hack]
git add <what you want to commit>
git commit [...]
git push dropbox HEAD:master


Substituting dropbox with an usb-stick will also work :-)

No comments:

Post a Comment