Git Branch - All about Branches in Git
One of the biggest strengths of git is its efficient and fast support of 'branches'. Before git, the most popular version systems were CVS and SVN and their branch support was very slow and in-efficient. Hence people used to avoid branches as much as possible.
With git, it is a pleasure to create and work on branches. With git, you can easily find developers creating separate branch for every feature, every release etc.
Git Branch - Basics
This section covers git branching basics covering operations like create, checkout, list, delete, rename etc.
git branch create
git checkout to create a new branch by providing
# create a new branch and switch to branch git checkout -b branch_name
git branch checkout
git checkout without
-b option is used to checkout or switch to existing branch.
# switch to existing branch git checkout branch_name
git branch list
# list existing branchs git branch # list existing branches including remote branches git branch -a
To see the branches with their last commit, you can use
# list branches with there last commit msg git branch -v
git branch delete
# delete a local branch git branch -d branch_name
git branch rename
# rename a local branch git branch -m old_name new_name # if you are already on old_name branch, you can omit it git branch -m new_name # update remote server with your local branch rename git push origin :old_name new_name # fix upstream tracking of remote branch git checkout new_name git push origin -u new_name