Last Updated: February 25, 2016
·
424
· wolfman0511

All about GIT BRANCH I know

In your github fork, you need to keep your master branch clean, i mean by clean without any changes, like that you can create at any time a branch from your master. Each time, that you want commit a bug or a feature, you need to create a branch for it, which will be somehow the copy of your master branch.
When you will do a pull request on a branch, you can continue to work on an another branch and make an another pull request on this other branch.

Before create a new branch pull the changes from upstream, your master need to be up to date.

Create the branch on your local machine :

$ git branch <nameofyournewbranch>

Push the branch on github :

$ git push origin <nameofyournewbranch>

Switch to your new branch :

$ git checkout <nameofyournewbranch>

When you want to commit something in your branch, be sure to be in your branch

You can see all branches created by using

$ git branch

Which will show :

  • approval_messages

master

master_clean

Add a new remote for you branch :

$ git remote add <nameofyour_remote> <url>

Push changes from your commit into your branch :

$ git push origin <nameofyour_remote>

Delete a branch on your local filesytem :

$ git branch -d <nameofyournewbranch>

Delete the branch on github :

$ git push origin :<nameofyournewbranch>
The only difference it's the : to say delete.

If you want to change default branch, it's so easy with github, in your fork go into Admin and in the drop-down list default branch choose what you want.

Original Article