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

Member

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

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

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

Member

by mac , 7 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.

Related Threads:

How to pull from master branch with git?
How to rebase git branch on master?
How to protect the master branch in git from merging?
How to move files from master to main branch in git?
How to switch to a new remote repo in git?
How to create a new branch in Git?