How to create a new branch?
- 1 Min. Read.
Creating a branch in git is very simple:
1 |
git branch <name> |
This will create a new local branch with the name you specified.
From the manpage:
With no arguments, existing branches are listed and the current branch will be highlighted with an asterisk.
How to push a new branch to remote?
Now that we’ve created this local branch, the next step is to push it to the remote:
1 |
git push -u origin <name> # This assumes you've already added a remote called 'origin' |
The -u
option is short for set upstream and this refers to the remote repository.