Ad

Git (CLI) Won't Let Me Switch Branches

- 1 answer

I have two branches in the local repository:

tool[email protected]:~/src/dev/auth-monitoring$ git branch
  dev-mar-21
* master

as you see I am on master (I swapped back to check something).

when I try to switch back to the dev branch I get:

[email protected]:~/src/dev/auth-monitoring$ git checkout -b dev-mar-21
fatal: A branch named 'dev-mar-21' already exists.

As usual I am clearly missing something!

Ad

Answer

The -b option is a request to first create a new branch before switching to it. You want to switch to an existing branch, so -b is not needed.

git checkout dev-mar-21
Ad
source: stackoverflow.com
Ad