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.
To check that you’ve switched to the correct branch, enter the following command in your terminal:
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:
The branch you’re currently on will be marked with an asterisk, as in the example below:
master * topic-branch
Use the command from the Summary to switch to the master branch and then back to the dev-branch.
Basic Branching and Merging from the Pro Git book