What does '--set-upstream' do?

前端 未结 3 946
我在风中等你
我在风中等你 2020-11-28 17:20

What does git --set-upstream do?

I tried to understand it by reading the git manual, but I didn\'t quite get it.

3条回答
  •  独厮守ぢ
    2020-11-28 17:53

    git branch --set-upstream 
    

    sets the default remote branch for the current local branch.

    Any future git pull command (with the current local branch checked-out),
    will attempt to bring in commits from the into the current local branch.


    One way to avoid having to explicitly type --set-upstream is to use its shorthand flag -u as follows:

    git push -u origin local-branch
    

    This sets the upstream association for any future push/pull attempts automatically.
    For more details, checkout this detailed explanation about upstream branches and tracking.


    To avoid confusion, recent versions of git deprecate this somewhat ambiguous --set-upstream option in favour of a more verbose --set-upstream-to option with identical syntax and behaviour

    git branch --set-upstream-to 
    

提交回复
热议问题