Switch a branch

git checkout branch_name

This command switches to the branch_name branch. It changes the working directory to the branch specified. The changes in the working directory are based on the branch you switch to. The branch_name is the name of the branch you want to switch to.

Example: Switch to the main branch

git checkout main

Note:

You can also use the shorthand git switch branch_name to switch branches. You can learn more about the git switch command in the Git Switch documentation.