Push to a new branch git
To push your local branch to a new branch on a remote repository using Git, you can use the following command:
git push -u origin <new-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).<new-branch-name>
is the name of the new branch you want to create on the remote repository.
For example, if you want to create a new branch called feature/new-login-system
on the remote repository, you would run:
git push -u origin feature/new-login-system
This will create a new branch on the remote repository and set the upstream tracking information for your local branch.
If you want to push an existing local branch to a new branch on the remote repository, you can use the following command:
git push origin <local-branch-name>:<new-branch-name>
Here:
<local-branch-name>
is the name of the local branch you want to push.<new-branch-name>
is the name of the new branch you want to create on the remote repository.
For example, if you want to push your local branch feature/login-system
to a new branch called feature/new-login-system
on the remote repository, you would run:
git push origin feature/login-system:feature/new-login-system
This will push the changes from your local branch to the new branch on the remote repository.