How to create a branch from another branch in Git

in Code Write a comment

In this tutorial, you’ll learn how to create a new branch from another branch with git and switch to it.

When you want to branch off from another branch you can use the following syntax.

$ git checkout -b <new_branch> <old_branch>

The <new_branch> should be replaced with the name of your new branch, while the <old_branch> is the name of the branch you want to branch off.


Hi, I'm Renat 👋

 


How to create a branch from develop branch in Git

To create a new branch from a develop branch, you can run the following command:

$ git checkout -b myFeature develop

This short command is the same as if you were running:

$ git checkout develop
$ git branch myFeature
$ git checkout myFeature

To push the current branch and set the remote as upstream, you can use:

$ git push --set-upstream origin myFeature

If you find this post useful, please let me know in the comments below. 
Cheers,
Renat Galyamov

Want to share this with your friends?
👉renatello.com/create-branch-from-another-branch-in-git

PS: Make sure you check JavaScript tutorials, e.g. remove item from an array of objects by object property in JavaScript.

Incoming search terms:

A collection of UI components for
Bootstrap 4/5 and Vue.js

Get now

Write a Comment

Comment

2 Comments