Git 2.0 RC 1 了,確認一下 push.default 設定。

[push]
  ; git 2.0 以前預設為 matching, 會將所有同名 branch push 出去
  ; git 1.7.6 以前可以用 tracking (deprecated),等於後來的 upstream
  ; git 1.7.11 開始可以使用 simple,即 2.0 預設值
  default = tracking
  default = simple

參考 git-config Documentation 的 push.default 條。 進行 git push,沒指定 refspec 時,舊預設值 matching 會把 local 的所有 branch,只要 remote 有一樣名字的就推出去。 但通常我們只會改一個 branch,也只有這個 branch 是要給別人看的,如果意外把其它 local branch 也推出去就糟了。 所以選 simple 比較適合,會先試 upstream 的作法把「目前的」branch 推到它的 upstream(可以用 git branch 或 git push 的 --set-upstream 設定,或直接在 .git/config 中設 [branch.foo] 的 remote);如果 git 找不到已知的 upstream,會再嘗試 current 作法,推到與目前 branch 同名的 branch。


看過 doc 後也順便改了:

  • Config 的各個 key 不分大小寫,但預設產生的是全小寫,於是手動改成 camelCase。
  • [log]
      abbrevCommit = true

    只顯示 hash 的前幾個字,這樣 tmux copy-mode 複製時,用 word selection 取到的東西比較簡短。

  • git branch 的 alias 預設加上 --verbose 選項。

    zshrc:

    alias gitb='git branch -v'

    git branch -v