git switch
is a newly introduced command to take some burden from git checkout
.
According to the manual of git checkout,
git checkout [<branch>]
To prepare for working on <branch>, switch to
it by updating the index and the files in the working tree, and by
pointing HEAD at the branch. Local modifications to the files in the
working tree are kept, so that they can be committed to the <branch>.
If is not found but there does exist a tracking branch in
exactly one remote (call it <remote>) with a matching name and
--no-guess is not specified, treat as equivalent to
$ git checkout -b <branch> --track <remote>/<branch>
So after you delete the branch and run git checkout <branch>
, it's created from <remote>/<branch>
again.
It also applies to git switch
.
git switch --no-guess
to disable automatic branch name creation via guessing mode. What you're doing is deleting the branch name, then creating a new name that's spelled the same. (Whether or not it identifies the same commit as before is another question entirely.) Note, however, that most people like--guess
mode, and it's the default. – Checkroom