I am working on a local branch (feature1) created from mainline branch. I would like to push this local branch to remote repository. How to achieve this in git along with tracking option.
Push a new Git branch to a remote repoClone the remote Git repo locally. Create a new branch with the branch, switch or checkout commands. Perform a git push with the –set-upstream option to set the remote repo for the new branch. Continue to perform Git commits locally on the new branch.
You can tell Git to track the newly created remote branch simply by using the -u flag with "git push".
To push the commit from the local repo to your remote repositories, run git push -u remote-name branch-name where remote-name is the nickname the local repo uses for the remote repositories and branch-name is the name of the branch to push to the repository. You only have to use the -u option the first time you push.
Push with the -u
option:
git push -u origin <branch>
-u
, short for --set-upstream
, that is set the upstream in origin
to the <branch>
name. If you omit the branch name, the local branch name is used instead. Full story on Git's documentation.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With