Tuesday, March 15, 2016

Using Git with Dropbox

http://blog.brandonbarker.net/2013/08/12/using-git-with-dropbox/

Using Git with Dropbox

I recently had a hard drive scare in which I almost lost a few solid months of part time work. So, as usual, I all of the sudden realized that constantly backing everything up is, in fact, quite important.
Now, i’m a firm believer and lover of version control systems and use Subversion daily, but I also absolutely love Git, so I try find any excuse to work with it. But I can’t always upload what i’m working on to GitHub and nobody got time for paying for private repos. So I got thinking, what if I could just host my repo’s on Dropbox? Turns out, it’s actually quite easy and loads of people are doing it (obviously, in typical South African fashion i’m late to this party – and I know there are loads of tutorials out there for this, but I need content for my first blog post, so what.)
Alright, so to start off open up Git Bash or your shell/terminal/command line tool of choice and cd into your project directory.
1
cd ~/Projects/MyProject
Then do the following
1
2
3
git init
git add .
git commit -m "First commit"
Now we need to create the directory that will house this repo on Dropbox, for eg. Dropbox/Repos/MyRepo.git
1
2
3
4
5
cd ~/Dropbox
mkdir Repos
cd Repos
mkdir MyRepo.git
cd MyRepo.git
And now we initialize a new Git repository and then link it to our project
1
2
3
4
git init --bare
cd ~/Projects/MyProject
git remote add origin ~/Dropbox/Repos/MyProject.git
git push -u origin master
That’s it! Now you can clone your repo from anywhere and rest assured that all your commits and pushes will be backed up securely to your Dropbox account. You can also publicly share your Dropbox URL with others and let them clone the repo, allowing you to collaborate on projects!

No comments: