git checkout --branch change

Use the git checkout command to change the branch.

git checkout branch name

The file and directory will switch to the commit content pointed to by the branch.

Why can I change the branch even if the working directory changes?

If there is a change in the working directory, git checkout will fail if you fix any inconsistencies in the branch you're switching to.

If there are no inconsistent corrections, the branch will switch while keeping the working directory changes.

How to create a branch?

For information on creating a branch, see the article on creating a branch.

Associated Information