git/list[1] front-page[2] threads[3] people[4] search[5] about
 

How to specify remote branch correctly

From
WWWoody Wu <narkewoody@gmail.com>
Date
Dec 17, 2012, 02:30 UTC
Message-ID
<slrnkct0r3.dsp.narkewoody@zuhnb712.local.com>
Hi, List

I have two branches in the remote, say, origin/master, origin/foo. Then when I tried to switch to the remote foo branch, the following two methods gave me different results:

1. git checkout foo
2. git checkout origin/foo

The first method run silently with success, but the second method complains that I got a 'detached HEAD'. So, I think I don't understand the difference between 'foo' and 'origin/foo'. Can someone give me a hint?

Supposing I have another remote defined in .git/config that points to another repository but also have a same name branch, say 'remote-x/foo', how do I tell git which 'foo' I want to switch to?

The similar problem also exists for 'fetch' command to me. From the man page, I don't find answer of how to specify which remote I am going to fetch from. Can you help me?

Thanks in advance.
-- 
woody
I can't go back to yesterday - because I was a different person then.
Next: Andrew Ardill
Message 1 of 11 in “How to specify remote branch correctly”
  1. Woody WuDec 17, 2012
  2. Andrew ArdillDec 17, 2012
  3. Woody WuDec 17, 2012
  4. Andrew ArdillDec 17, 2012
  5. Tomas CarneckyDec 17, 2012
  6. Andrew ArdillDec 17, 2012
  7. Chris RorvickDec 17, 2012
  8. Woody WuDec 17, 2012
  9. Tomas CarneckyDec 17, 2012
  10. Woody WuDec 17, 2012
  11. Woody WuDec 17, 2012

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.