facebook

Easy And Helpful Steps Of Creating A New Branch With Git

By Aheli Bharadwaj

Easy And Helpful Steps Of Creating A New Branch With Git

When you do a pull request on a branch, you’ll be able to still work on another branch and create another pull request on this other branch.

Before creating a completely new branch, pull the changes from upstream. Your master needs to be up to date.

$ git pull

Create the branch on your native machine and switch in this branch :

$ git checkout -b [new branch name]

Push the branch on github :

$ git push origin [new branch name]

When you need to commit something in your branch, make sure to be in your branch. Add -u parameter to set upstream.

You can see all the branches created by using :

$ git branch -a

Which will show :

* approval_messages
  master
  master_clean

Add a new remote for your branch :

$ git remote add [remote branch name][new branch name]

Push changes from your commit into your branch :

$ git push [remote branch name] [url]

Update your branch first once the original branch from the official repository has been updated :

$ git fetch [remote branch name]

Then you need to apply to merge changes if your branch is derivated from develop you need to do :

$ git merge [remote branch name]/develop

Delete a branch on your local filesystem :

$ git branch -d [new branch name]

To force the deletion of local branch on your filesystem :

$ git branch -D [new branch name]

Delete the branch on github :

$ git push origin :[new branch name]

If you want to create a new branch:

$ git branch [new branch name]

Aheli Bharadwaj Subscriber
Web Designer , Openweb Solutions

Web Designer and tech enthusiast at Openweb Solutions. I love to learn about new technologies and share the idea with others.

Posts created 5

Begin typing your search term above and press enter to search. Press ESC to cancel.

Back To Top
shares