Home > Software design >  git (CLI) won't let me switch branches
git (CLI) won't let me switch branches

Time:02-05

I have two branches in the local repository:

tools@secmgrprd02:~/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:

tools@secmgrprd02:~/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!

CodePudding user response:

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
  •  Tags:  
  • Related