Git checkout new branch
A common Git command!
git checkout -b <branch-name>
creates a new branch and switches to it.
Here's a breakdown of the command:
checkout
: This command is used to switch between branches, create a new branch, or discard changes.-b
: This option tells Git to create a new branch and switch to it. If you omit this option, Git will only switch to an existing branch.<branch-name>
: Replace this with the name you want to give your new branch.
Example:
git checkout -b feature/new-login-system
This command creates a new branch named feature/new-login-system
and switches to it. You can then make changes, commit them, and eventually merge the branch back into the main branch (e.g., master
).
Note: If you want to create a new branch without switching to it, you can use git branch <branch-name>
instead.