Search code examples
gitgithubversion-controlgit-branchgit-remote

What is the difference between git "set-upstream-to" and "track" options


Recently, I tried to set my local branch feature to track changes on my remote branch like this:

$ git branch --set-upstream feature origin/feature

Everything went well, but I got that message saying:

The --set-upstream flag is deprecated and will be removed. Consider using --track or --set-upstream-to

My question is how to use the track and set-upstream-to options and if there is a significant difference between them.

UPDATE: I'm using git version 1.8.4


Solution

  • In Git a branch that tracks (or has an upstream) has the an entry similar to the following in the repository config file (/.git/config)

    [branch "feature"]
            remote = origin
            merge = refs/heads/feature
    

    The "--set-upstream" option you have been using has been directly replaced with "--track"

    so

    git branch --track feature origin/feature
    

    additionally there is a new syntax like

    git branch --set-upstream-to=origin/feature feature
    

    and also

    git branch -u origin/feature feature
    

    All forms function identically.