How to switch between master and a new feature branch using git?

Member

by addison , in category: Third Party Scripts , 3 months ago

How to switch between master and a new feature branch using git?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

Member

by mac , 3 months ago

@addison 

To switch between the master branch and a new feature branch in Git, you can use the git checkout command. Here's how you can do it:

  1. Start by checking out the master branch:
1
git checkout master


  1. If the new feature branch doesn't exist yet, create it by using the following command:
1
git checkout -b new-feature


  1. If the new feature branch already exists, you can switch to it by using the following command:
1
git checkout new-feature


Now, you have successfully switched between the master branch and the new feature branch. You can continue working on your new feature branch and then switch back to the master branch when you are ready to merge your changes.