Help us understand the problem. What is going on with this article?

Git でブランチの名前を変更する方法

More than 5 years have passed since last update.


今関わっているプロジェクトでは、トピックブランチの名前に prefix としてスプリントの番号(現在プロジェクト開始から何スプリント目か)をつけることになっている。


% git branch -m <newbranch>


% git branch -m [oldbranch] <newbranch>


% git branch -M <newbranch>


% git branch -M [oldbranch] <newbranch>

git branch -h の結果

% git branch -h
usage: git branch [options] [-r | -a] [--merged | --no-merged]
   or: git branch [options] [-l] [-f]  []
   or: git branch [options] [-r] (-d | -D) ...
   or: git branch [options] (-m | -M) [] 

Generic options
    -v, --verbose         show hash and subject, give twice for upstream branch
    -q, --quiet           suppress informational messages
    -t, --track           set up tracking mode (see git-pull(1))
    --set-upstream        change upstream info
    -u, --set-upstream-to 
                          change the upstream info
    --unset-upstream      Unset the upstream info
    --color[=]      use colored output
    -r, --remotes         act on remote-tracking branches
    --contains    print only branches that contain the commit
    --abbrev[=]        use  digits to display SHA-1s

Specific git-branch actions:
    -a, --all             list both remote-tracking and local branches
    -d, --delete          delete fully merged branch
    -D                    delete branch (even if not merged)
    -m, --move            move/rename a branch and its reflog
    -M                    move/rename a branch, even if target exists
    --list                list branch names
    -l, --create-reflog   create the branch's reflog
    --edit-description    edit the description for the branch
    -f, --force           force creation (when already exists)
    --no-merged   print only not merged branches
    --merged      print only merged branches
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away