cancel
Showing results for 
Search instead for 
Did you mean: 
cvrr
Cadet
Cadet
  • 2,186 Views

What does --set-upstream doess

do180-4.10 course
ch01
s07

Section 5.5 has below command

git push --set-upstream origin testbranch

if we remove --set-upstream, would it make any difference?

Labels (1)
2 Replies
Chetan_Tiwary_
Moderator
Moderator
  • 2,161 Views

Hello @cvrr !

Yes that would make a difference !

--set-upstream tells Git to set the upstream branch for the current local branch.  The upstream branch is the branch on the remote repository that you want to keep your local branch synchronized with.

If you use the same without --set-upstream --> It will still push it to the remote repo but it wont set the upstream for testbranch.

So the difference you will see during pulling,

if you don't use --set-upstream , you have to do:

git pull origin <branch>


But if you do:  git push --set-upstream origin <branch>
then, when pulling, you only have to do:  git pull

  • 2,069 Views

The --set-upstream option in git push links your local branch to the corresponding remote branch. This means that, in the future, you can just use git pull or git push without specifying the branch. If you remove --set-upstream, the push will work for that instance, but the upstream link won't be set, so you'll need to specify the remote branch in subsequent pulls or pushes for that local branch.

Regards
Ben jonson
Join the discussion
You must log in to join this conversation.