多台電腦 git repository 最簡單的同步方式,應該是把 .git 目錄放在 Dropbox 底下。

在 repository 直接編輯 .git/config,加進一個叫做 {dropbox}remote,url 設成 Dropbox 下的目錄;
再配合該 remote 設定一個叫 {wip}branch。(後面有範例)

然後 cd 到 {dropbox} 目錄,把剛設的 remote url 建立起來: git init --bare

日後只要在 {wip} branch 做 git pullpush 就都是對 Dropbox 動作了。


我在 GitHub fork 別人專案後,通常會建一個 [remote "dropbox"],配合 [branch "wip"] 自己亂改。 寫到一個段落再整理進 master,另外 upstream branch 則是用來跟原作者的進度。

常用 .git/config 樣板

[core]
  repositoryformatversion = 0
  filemode = true
  bare = false
  logallrefupdates = true

[remote "origin"]
  fetch = +refs/heads/*:refs/remotes/origin/*
  url = git@github.com:{ME}/{PROJECT}.git
[remote "upstream"]
  fetch = +refs/heads/*:refs/remotes/upstream/*
  url = git://github.com/{AUTHOR}/{PROJECT}.git
[remote "dropbox"]
  fetch = +refs/heads/*:refs/remotes/dropbox/*
  url = /home/bootleq/dropbox/repository/bare/{PROJECT}/

[branch "master"]
  remote = origin
  merge = refs/heads/master
[branch "upstream"]
  remote = upstream
  merge = refs/heads/master
[branch "wip"]
  remote = dropbox
  merge = refs/heads/wip


; vim: filetype=gitconfig