Checkout to a Branch on Local Machine Linked With Same Branch on Remote Origin

We can know all the existing branches of any project by git branch -a. It gives output something like

* master
some_feature_branch
remotes/origin/HEAD -> origin/master
remotes/origin/master-some_feature_branch
remotes/origin/master-some_another_feature_branch
  • `* master` tell the current branch.
  • Branch names starting from `remotes` tell us that branch is at remote server.
  • Branch name with `->` tells us to which remote branch local branch is mapped with.

Now to create a new local branch mapped with remote branc, assuming remotes/origin/master-some_another_feature_branch do

git checkout -b master-some_another_feature_branch origin/master-some_another_feature_branch

Now the new local branch is created, mapped with remote branch.

Comments