we can ceate a branch form commit id or sha code or head number

create branch from commit id or sha code



by using above command you can create a new branch from commit id or sha code

create branch from head number


git branch devops  HEAD@{0}

it will create a branch name called ‘devops’ from latest commit since we mentioned HEAD@{0}

HEAD@{0} represnts the latest commit

HEAD@{1} represnts 1 commit before

HEAD@{2} represnts 2 commits before


create branch from commit id and checkit out

If you want to check out the new branch as you create it you can use this command

git checkout -b devops <commit-id>

This will create a new branch called ‘devops’ and check it out.

create branch from HEAD and checkit out

this will also create branch and check it out. So you can use anyone of above commands

push branch to remote repository or git-hub or bit-bucket

above commands will only create a branch in local repository not in remote repository. so you need to push the newly created branch to remote git-hub or bit-bucket. for that we use below command.



  • git create branch from commit id
  • git create branch from head number