Creating a branch inside a branch in git

In my repository I have a leading branch and then an intermediate branch coming out of the main branch. Now I need to add a third branch, which should exit the intermediate branch. This means that I need a branch coming out of another branch. Can anyone help with this?

The syntax I used to create the branch is as follows:

git branch <name_of_your_new_branch> git push origin <name_of_your_new_branch> git checkout <name_of_your_new_branch> 
+6
source share
1 answer

This can create a local branch:

 git checkout staging git checkout -b newBranch 

or, one line:

 git checkout -b newBranch staging 

This will start with the current HEAD staging , but note that the branch does not actually come from another branch: it comes from a commit (and this commit can be part of several branches).

Then you can push the new branch tracking the remote branch with one command:

 git push -u origin newBranch 
+6
source

All Articles