Search code examples
gitgit-worktree

How can I rename a git worktree


Given I have run

$ git worktree add ~/worktrees/a
$ cd ~/worktrees/a
$ git status
On branch a

I would like to instead change the name of the worktree and branch from a to b.


Solution

  • One option for achieving this (that I ended up doing) is:

    $ git worktree move ~/worktrees/a ~/worktrees/b
    $ cd ~/worktrees/b
    $ git branch -m b