title: How to make an existing branch track a remote branch?
body: <p>I'm trying to track an exiting branch to a remote branch using <code>--track</code> or <code>--set-upstream-to</code>, but got the following error</p>
  
  <pre><code>$ git branch --track master origin/master
  fatal: A branch named 'master' already exists.   
  $ git branch --set-upstream-to master origin/master
  fatal: branch 'origin/master' does not exist   
  </code></pre>
  
  <p>I checked SourceTree and found that it uses <code>--set-upstream</code>, but got the following warning </p>
  
  <pre><code>$ git branch --set-upstream master origin/master
  The --set-upstream flag is deprecated and will be removed. Consider using --track or --set-upstream-to
  Branch master set up to track remote branch master from origin.
  </code></pre>
  
  <p>Both <code>--track</code> and <code>--set-upstream-to</code> is not working, Am I missing something?</p>