-
Notifications
You must be signed in to change notification settings - Fork 7
Creating and using branches with Git
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 uptodate.
Create the branch on your local machine :
$ git branch <name_of_your_new_branch>
Push the branch on github :
$ git push origin <name_of_your_new_branch>
Switch to your new branch :
$ git checkout <name_of_your_new_branch>
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 <name_of_your_remote> <url>
Push changes from your commit into your branch :
$ git push origin <name_of_your_remote>
Delete a branch on your local filesytem :
$ git branch -d <name_of_your_new_branch>
Delete the branch on github :
$ git push origin :<name_of_your_new_branch>
Note: ':' tells git to delete the branch.
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.