← Writing

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

{{< highlight bash >}} git branch new_branch base_branch git checkout new_branch {{< / highlight >}}

Only with git checkout

{{< highlight bash >}} # 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 {{< / highlight >}}