Create and remove the GIT branch : Branching is the feature of GIT, which is needed when you want to add new functionality in your application without being changed to old version. So you need to create a branch which will be copy of your last version and everything you change in this new branch will not effect to last version.
So below are the steps to create branch on GIT repository :
Step 1 : Following command to create new branch called 'mybranch'
$ git branch mybranch
This will create the branch called mybranch
Step 2: Now we need to switch our main branch 'master' to new branch 'mybranch'.
$ git checkout mybranch
Now we are inside our new branch called 'mybranch'.
Step 3: Now add new file or modify exist files in this branch and then run following command.
$ git add all
$ git commit -m New changes in branch.
Everything is done and we have new branch which has new changes. Now all the new changes are commited.
Step 4: In case where we need to update our old version and need to put all new features into old version, then we need to merge the new code to our last code. Merge the updated branch code into the last version 'master ' :
a) go to the master branch
$ git checkout master
b) run merge command
$ git merge mybranch
Now the all changes we have made in mybranch will be merge into master branch.
Step 5 : Check number of branches : following command show all local branches
$ git branch
Step 6 : Now we have all our new changes merged to the last version 'master'. So if you don't need this branch 'mybranch' then following is the command to delete the local branch.
$ git branch -D mybranch
The above command will delete the 'mybranch' branch.