Skip to main content
  1. Learn
  2. Software Development
  3. Guides
  4. Git tutorial
  5. How to use Git
  6. How to use branching in Git
  7. Switch to a branch
GuidesSoftware DevelopmentBacklog

Project and code management together.

Switch to a branch

You just created a branch now you'll need to switch to that branch to add new commits to it.

Use the git checkout command to switch to the branch issue1.

$ git checkout issue1
Switched to branch 'issue1'

Now, the history looks like this:

Current history

Use the -b option to create a new branch and switch to it with one command.

Next, let’s add a commit. Add the bold text below to the myfile.txt file.

Anyone can learn Git with this tutorial and Backlog add: Register a change in an index

And commit the change.

$ git add myfile.txt
$ git commit -m "append description of the add command"
[issue1 b2b23c4] append description of the add command
 1 files changed, 1 insertions(+), 0 deletions(-)

The history now looks like this:

Current history

Subscribe to our newsletter

Learn with Nulab to bring your best ideas to life