How to checkout a new branch from other branch or tag with git checkout

Today I learned a new way to checkout a new branch from other branch or a tag.

Normal way width git branch & git checkout

git branch new_branch base_branch
git checkout new_branch

Only with git checkout

# creates and checkout the new branch from the base branch
git checkout base_branch -b new_branch
# creates and checkout the new branch from the tag
git checkout tag_name -b new_branch
comments powered by Disqus