Use Dropbox as a simple Git repository server

Git is so popu­lar nowa­da­ys and we are using Github to save all our dai­ly work the­re. But if we want to save some priva­te or indivi­dual testing pro­je­cts, and do not want to pay for Github priva­te repo­si­to­ry, we may use Dro­pbox as Git repo­si­to­ry server.

Of cou­r­se you may think of using “git init” dire­ctly, but it will not have abi­lia­ty to sha­re with multi­ple lapto­ps or par­t­ners. And for the second time you may think of filling the who­le pro­je­ct with git ini­tia­li­zed into Dro­pbox folder tota­lly, but when compi­ling your pro­je­ct or testing it, a lof of tempo­ra­ry files will be gene­ra­ted and saved to Dro­pbox endle­ss.

So here goes my solu­tion. Save our own pro­je­ct loca­lly with git ena­bled, and use Dro­pbox folder as a ‘remo­te’ Git repo­si­to­ry server.

Fir­st of all, you may need to open ssh servi­ce on your laptop and give cor­re­ct acce­ss of you­r­se­lf to you­r­se­lf. We will use ssh to con­ne­ct git to our local Dro­pbox folder. You may copy your ~/.ssh/id_rsa.pub into ~/.ssh/authorized_keys, and make sure you can run ‘$ ssh loginname@localhost’ without ente­ring passwo­rd.

Then, you may need to ini­tia­li­ze a git folder inner ~/Dropbox, like run­ning:
$ mkdir -p ~/Dropbox/repository/YOUR_PROJECT_NAME
$ cd ~/Dropbox/repository/YOUR_PROJECT_NAME
$ git init

For the next step, you may clo­ne this pro­je­ct by run­ning:
$ cd ~/PROJECT_FOLDER/
$ git clo­ne loginname@localhost:~/Dropbox/repository/YOUR_PROJECT_NAME

Then you will find your pro­je­ct is rea­dy for use of remo­te git repo­si­to­ry.

Plea­se note you may be not push your local code into Dro­pbox git bran­ch ‘master’, sin­ce cur­ren­tly Dro­pbox git repo­si­to­ry is under master bran­ch. You may crea­te a new bran­ch and push into that one, or che­ckout your Dro­pbox git bran­ch into ano­ther one. It’s up to you.

This is my con­fig file of local git repo­si­to­ry:

$ cat .git/config
[core]
    repo­si­to­r­yfo­r­ma­tver­sion = 0
    file­mo­de = true
    bare = false
    loga­ll­re­fu­pda­tes = true
    igno­re­ca­se = true
    pre­co­mpo­seu­ni­co­de = false
[remo­te “ori­gin”]
    url = paul@localhost:/Users/paul/Dropbox/repository/my-project
    fetch = +refs/heads/*:refs/remotes/origin/*
[bran­ch “master”]
    remo­te = ori­gin
    mer­ge = refs/hea­ds/­re­mo­st-master

And also con­fig file of Dro­pbox git repo­si­to­ry:

$ cat .git/config
[core]
    repo­si­to­r­yfo­r­ma­tver­sion = 0
    file­mo­de = true
    bare = false
    loga­ll­re­fu­pda­tes = true
    igno­re­ca­se = true

You may also like...

Leave a Reply

Your email address will not be published.

seven + 16 =

使用新浪微博登陆