title: Get remote name from local branch
body: <p>How to get the remote name from a local branch?</p>
  
  <p>Note that I do not want the remote tracking branch name but just the remote name. </p>
  
  <p>Consider this contrived example. How do I get <code>prefix/github</code>?</p>
  
  <pre><code>$ git status -b
  ## dev...prefix/github/rm/dev
  
  $ git remote
  github
  prefix
  prefix/github
  </code></pre>
  
  <p>So <code>prefix/github</code> is the remote and local branch <code>dev</code> is tracking remote branch <code>rm/dev</code>.</p>
  
  <p>So far I know this way but it is not fullproof.</p>
  
  <pre><code>$ git rev-parse --abbrev-ref @{u} 2&gt;/dev/null | cut -d'/' -f1
  prefix
  </code></pre>
  
  <p>The <code>prefix/github</code> remote name is intentional. I can live with keeping my remote without forward slash (in which case the above would work) but wanted to know if I'm missing something. </p>
  
  <p>fyi: I have a bash script where this eventually would be used.</p>
  
  <p>Update:</p>
  
  <p>See this comment for why this question is not a dupe:
  <a href="https://stackoverflow.com/questions/43431277/get-remote-name-from-local-branch#comment73921535_43431277">Get remote name from local branch</a></p>