Branch From Another Git Branch

less than 1 minute read

This will be needed when you want to start a development branch where the code is based on code that was committed in another branch and not the ‘Develop’ branch.

Aside: If you already created the new branch incorrectly you can delete it using git branch -D feature/name-of-branch

  1. To see the list of currently checked out branches, and which branch you are currently in, use git branch. Ensure you are currently in the branch that you want to branch from.

  2. To create the new branch use git checkout -b feature/name-of-new-branch.

  3. Push the branch to remote using git push --set-upstream origin feature/name-of-new-branch.

You will automatically be switched to the newly created branch. If you wish to switch branch, use the command git checkout feature/name-of-new-branch.

Tags:

Updated: