Git push new branch
To push a new branch to a remote repository using Git, you can use the following command:
git push -u origin <branch-name>
Here:
git push
is the command to push changes to a remote repository.-u
is an option that sets the upstream tracking information for the branch. This means that Git will automatically track the remote branch and update it when you pull or push changes.origin
is the name of the remote repository (usually the default name for the remote repository you cloned from).<branch-name>
is the name of the new branch you want to create and push.
For example, if you want to create a new branch called feature/new-login-system
and push it to the remote repository, you would run:
git push -u origin feature/new-login-system
This will create the new branch on the remote repository and set the upstream tracking information for the branch.
If you want to push an existing local branch to a remote repository, you can use the same command without the -u
option:
git push origin <branch-name>
For example:
git push origin feature/new-login-system
This will push the existing local branch feature/new-login-system
to the remote repository.