[Git] ローカルとリモートのブランチ名を変更する

memo.

ローカル

% git branch -m add_omnigraffle-pro5 add_omnigraffle-pro5_spike
% git branch
* add_omnigraffle-pro5_spike
  master

リモート

% git branch --all
* add_omnigraffle-pro5_spike
  master
  remotes/origin/HEAD -> origin/master
  remotes/origin/add_omnigraffle-pro5
  remotes/origin/master
  remotes/upstream/master

一度削除して、push し直す。

% git push origin :add_omnigraffle-pro5
To git@github.com:DriftwoodJP/homebrew-versions.git
 - [deleted]         add_omnigraffle-pro5
% git push -u origin add_omnigraffle-pro5_spike
Counting objects: 8, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (4/4), done.
Writing objects: 100% (4/4), 518 bytes | 0 bytes/s, done.
Total 4 (delta 2), reused 0 (delta 0)
To git@github.com:DriftwoodJP/homebrew-versions.git
 * [new branch]      add_omnigraffle-pro5_spike -> add_omnigraffle-pro5_spike
Branch add_omnigraffle-pro5_spike set up to track remote branch add_omnigraffle-pro5_spike from origin.
% git branch --all
* add_omnigraffle-pro5_spike
  master
  remotes/origin/HEAD -> origin/master
  remotes/origin/add_omnigraffle-pro5_spike
  remotes/origin/master
  remotes/upstream/master

補遺

-u, --prune あたりを再度調べる。