git checkout <branchname>
Switch to a different branch
This command allows you to switch to a different branch in your Git repository.
It updates the working directory and the index to match the contents of the specified branch. By providing the branch name as an argument, you can easily change to that branch.
If you want to create a new branch and switch to it at the same time, you can use the flag -b
flag. Additionally, you can use the flag -t
or --track
to set up a tracking branch.
Specific examples:
git checkout main
Sign in to enable bookmarking, reminders, progress-tracking and more...
Related
git checkout -b <branchname>
git checkout -b <branchname1> <remote>/<branchname2>
git checkout -
git checkout --<pathname>
git checkout HEAD <pathname>
git checkout --ours <pathname>
git checkout --theirs <pathname>
git checkout -m <branchname>
git checkout --orphan <branchname>
git checkout -b <branchname> <commit>
git checkout -t <remote>/<branchname>