Forrest logo
back to the git tool

git-branch:tldr:6a51b

git-branch: Create new branch based on a specific commit.
$ git branch ${branch_name} ${commit_hash}
try on your machine

This command creates a new branch in Git called ${branch_name} at a specific ${commit_hash}. Here's a breakdown of the command:

  • git branch: This is the main command that deals with branches in Git.
  • ${branch_name}: This is a placeholder for the desired name of the new branch. You would replace ${branch_name} with an actual name, like "feature/xyz" or "bugfix/123".
  • ${commit_hash}: This is the specific commit hash (also known as the commit ID or SHA-1 hash) from which you want to create the new branch. It indicates the exact point in the Git history where you want to start the new branch. You would replace ${commit_hash} with the appropriate hash.

By running this command, Git will create a new branch named ${branch_name} that starts from the commit specified by ${commit_hash}. This allows you to create branches at specific points in the project's history, enabling you to work on different features, bug fixes, or experiments concurrently.

This explanation was created by an AI. In most cases those are correct. But please always be careful and never run a command you are not sure if it is safe.
back to the git tool