Skip to content

Try our new Crash Courses!

Buy one of our new Crash Courses, now hosted on Teachable.

Switch branches – Git

Summary

To switch branches in Git, enter the following command in your terminal:

git checkout branch-name

Replace branch-name with the name of the branch you want to switch to.

Details

To check that you’ve switched to the correct branch, enter the following command in your terminal:

git status

The branch you’re currently on should print out on the next line.

You can also list all of your branches available by entering the following command in your terminal:

git branch

The branch you’re currently on will be marked with an asterisk, as in the example below:

  master
* topic-branch

Exercises

Use the command from the Summary to switch to the master branch and then back to the dev-branch.

References

Basic Branching and Merging from the Pro Git book

Back to: Git Reference > Git Intermediate