title: How to create git Remote-Tracking Branch
body: <p><a href="https://www.git-tower.com/learn/git/faq/track-remote-upstream-branch" rel="nofollow noreferrer">They said</a> that is it as simple as</p>
  
  <blockquote>
    <p>You can tell Git to track the newly created remote branch simply by using the -u flag with "git push".</p>
  </blockquote>
  
  <p>But it never worked for me. </p>
  
  <p>How to create the git Remote-Tracking Branch, with which</p>
  
  <blockquote>
    <p>Git can now inform you about "unpushed" and "unpulled" commits.</p>
  </blockquote>
  
  <p>Here is mine:</p>
  
  <pre><code>$ git status 
  On branch newfeature/v4-json
  nothing to commit, working tree clean
  </code></pre>
  
  <p>vs what I'm expecting, quoting from <a href="https://www.git-tower.com/learn/git/faq/track-remote-upstream-branch" rel="nofollow noreferrer">above article</a>:</p>
  
  <pre><code>$ git status
  # On branch dev
  # Your branch and 'origin/dev' have diverged,
  # and have 1 and 2 different commits each, respectively.
  #
  nothing to commit (working directory clean)
  </code></pre>
  
  <p>I.e., info about the "unpushed" and "unpulled" commits.<br>
  I.e., I want to see the same as:</p>
  
  <pre><code>$ git status
  On branch master
  Your branch is ahead of 'origin/master' by 3 commit.
    (use "git push" to publish your local commits)
  
  nothing to commit, working tree clean
  </code></pre>
  
  <p>Yet from my above actual output, you can see that i'm not able to see how many commits I've made so far anymore, <em>despite that I've made several commits</em>. </p>
  
  <p>This is what I did:</p>
  
  <pre><code>$ git push -u origin newfeature/v4-json
  Counting objects: 12, done.
  Delta compression using up to 2 threads.
  Compressing objects: 100% (11/11), done.
  Writing objects: 100% (12/12), 1.87 KiB | 958.00 KiB/s, done.
  Total 12 (delta 9), reused 0 (delta 0)
  remote: Resolving deltas: 100% (9/9), completed with 9 local objects.
  remote: 
  remote: Create a pull request for 'newfeature/v4-json' on GitHub by visiting:
  remote:      https://github.com/.../pull/new/newfeature/v4-json
  remote: 
  To github.com:xxx/yyy.git
   * [new branch]      newfeature/v4-json -&gt; newfeature/v4-json
  Branch 'newfeature/v4-json' set up to track remote branch 'newfeature/v4-json' from 'origin' by rebasing.
  </code></pre>
  
  <p>But I don't have such remote tracking branch 'newfeature/v4-json' from 'origin' set up by <code>git</code>:</p>
  
  <p>A) <code>git remote show origin</code> does not show a remote tracking branch for my newfeature at all:</p>
  
  <pre><code>$ git remote show origin
  * remote origin
    Fetch URL: git@github.com:go-easygen/easygen.git
    Push  URL: git@github.com:go-easygen/easygen.git
    HEAD branch: master
    Remote branch:
      master tracked
    Local branches configured for 'git pull':
      master             rebases onto remote master
      newfeature/v4-json rebases onto remote newfeature/v4-json
    Local refs configured for 'git push':
      master             pushes to master             (up to date)
      newfeature/v4-json pushes to newfeature/v4-json (up to date)
  </code></pre>
  
  <p>while the following is what I want to see, according to <a href="http://www.gitguys.com/topics/adding-and-removing-remote-branches" rel="nofollow noreferrer">http://www.gitguys.com/topics/adding-and-removing-remote-branches</a></p>
  
  <pre><code>$ git remote show origin
  * remote origin
    Fetch URL: /tmp/.../git/rp0
    Push  URL: /tmp/.../git/rp0
    HEAD branch: master
    Remote branches:
      master     tracked
      newfeature tracked
    Local branches configured for 'git pull':
      master     rebases onto remote master
      newfeature rebases onto remote newfeature
    Local refs configured for 'git push':
      master     pushes to master     (up to date)
      newfeature pushes to newfeature (up to date)
  </code></pre>
  
  <p>Note in the <code>Remote branches:</code> section, besides <code>master tracked</code>, there is also a <code>newfeature tracked</code>. This <code>newfeature tracked</code> is called <em>remote tracking branch</em> as per above article. </p>
  
  <p>B) neither is <code>git branch -a</code>:</p>
  
  <pre><code>$ git branch -a
    master
  * newfeature/v4-json
    remotes/origin/HEAD -&gt; origin/master
    remotes/origin/master
  </code></pre>
  
  <p>There is only one <code>remotes/origin/master</code> remote tracking name there, while I'm expecting more. E.g. (irrelevant but just to show the case with more remote tracking names), </p>
  
  <pre><code>$ git branch -a
  * master
    remotes/origin/HEAD
    remotes/origin/master
    remotes/origin/v1.0-stable
    remotes/origin/experimental
  </code></pre>
  
  <p>C) nor is <code>git branch -vv</code>:</p>
  
  <pre><code>$ git branch -vv
    master             75369c3 [origin/master] - [*] allow ...
  * newfeature/v4-json 8c98d9c - [*] update ...
  </code></pre>
  
  <p>while I'm expecting to see, </p>
  
  <pre><code>$ git branch -vv
    master             75369c3 [origin/master] - [*] allow ...
  * newfeature/v4-json 8c98d9c [origin/newfeature/v4-json] - [*] update ...
  </code></pre>
  
  <p>Moreover,</p>
  
  <p><code>git pull</code> is not updating my <em>local</em> branch from <em>remote</em> either:</p>
  
  <pre><code>$ git pull
  From github.com:xxx/yyy
   * branch            newfeature/v4-json -&gt; FETCH_HEAD
  Already up to date.
  Current branch newfeature/v4-json is up to date.
  
  $ git pull
  From github.com:xxx/yyy
   * branch            newfeature/v4-json -&gt; FETCH_HEAD
  Already up to date.
  Current branch newfeature/v4-json is up to date.
  
  $ git pull
  From github.com:xxx/yyy
   * branch            newfeature/v4-json -&gt; FETCH_HEAD
  Already up to date.
  Current branch newfeature/v4-json is up to date.
  </code></pre>
  
  <p>I.e., no matter how many time I pull, I'm not getting the same output as, </p>
  
  <pre><code>$ git pull
  Already up to date.
  Current branch master is up to date.
  </code></pre>
  
  <p>All above is <strong><em>not</em></strong> normal. I've created Remote-Tracking Branch with MS VS before many times, and the results are exactly as what I am expecting, not above. However, I don't like the black magic tricks, so I want to know how I can do the same with plain <code>git</code>. </p>
  
  <p>So what is the correct way to create git Remote-Tracking Branch?</p>