fatal: a branch named 'feature' already exists means you asked Git to create a branch whose name is taken. To use the existing branch, switch to it without -b or -c: git switch feature. To start the name over from where you are now, use git switch -C feature, which resets it.

Check what the existing branch holds before you reset it: a capital -C moves the name to your current commit, and commits only that branch had are left without a name.

The error

PS> git branch feature
fatal: a branch named 'feature' already exists

PS> git checkout -b feature
fatal: a branch named 'feature' already exists

PS> git switch -c feature
fatal: a branch named 'feature' already exists

All three exit with code 128 and change nothing: you stay on the branch you were on, and the existing feature keeps pointing at the same commit. The message is the same whichever of the three create commands you used, so the fix is the same too.

Why it happens

git branch NAME, git checkout -b NAME and git switch -c NAME all mean "create". Branch names are unique in a repository, so when the name is already in git branch --list, creation fails. It usually happens when you copy a "create the branch" command from a tutorial or a ticket a second time, when a script that creates a branch runs twice, or when you created the branch earlier and forgot.

The fix

Use the branch that is already there:

PS> git switch feature
Switched to branch 'feature'

Or recreate it at your current commit on purpose:

PS> git switch -q main
PS> git switch -C feature
Switched to and reset branch 'feature'
PS> git branch --list
* feature
  main

git switch without -c only moves you to the branch. -C (capital) creates the branch, or resets it if it already exists, to the commit you are on, and switches to it; the output says "reset" so you know which happened. If you meant a different branch, pick another name; git branch --list shows the names already taken.

How it was reproduced

Git for Windows 2.45.2 on Windows 11, Windows PowerShell 5.1, in a throwaway repository with one commit. After git branch feature, a second git branch feature, git checkout -b feature and git switch -c feature each failed with exit code 128. git switch feature and git switch -C feature both succeeded.

Frequently asked

How do I switch to a branch that already exists in git?
Run git switch with the branch name and no -c, or git checkout with the name and no -b. The create flags are what cause a branch named already exists.
How do I overwrite an existing branch in git?
git switch -C name resets the branch to your current commit and switches to it. Commits only that branch had are left without a branch name, so check them first.
Does a branch named already exists change anything?
No. Git exits with code 128 before creating or switching anything, so your branches and working tree stay as they were.

More decoded errors in the Fixes category. For what a branch is and how switching works, see Git branches explained.