What command is used to set the upstream branch for the current branch?
Posted by JackBrn
Last Updated: June 10, 2024
To set the upstream branch for the current branch in Git, you can use the following command:
git push -u origin <branch-name>
Replace <branch-name> with the name of the branch you want to track. The -u (or --set-upstream) flag sets the upstream reference, allowing you to use commands like git pull and git push without having to specify the branch each time. Alternatively, if you have already created a branch locally and you want to set an upstream branch after the fact, you can use:
git branch --set-upstream-to=origin/<branch-name>
This command also sets the upstream branch for the current branch.
Related Content