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

git push on tracking branches

From
SBStephen Bash <bash@genarts.com>
Date
Sep 27, 2010, 16:00 UTC
Message-ID
<15793457.371451.1285603241207.JavaMail.root@mail.hq.genarts.com>
In-Reply-To
<6958088.371432.1285602164529.JavaMail.root@mail.hq.genarts.com>
Hi all-
A coworker alerted me to some strange behavior with git push on tracking branches (maybe a documentation error?).  Pro Git (http://progit.org/book/ch3-5.html) says:
"To set up a local branch with a different name than the remote branch, you can easily use the first version with a different local branch name:
   $ git checkout -b sf origin/serverfix
   Branch sf set up to track remote branch refs/remotes/origin/serverfix.
   Switched to a new branch "sf"
Now, your local branch sf will automatically push to and pull from origin/serverfix."
When I do this on my local machine (current master on Mac 10.6.4):
snowg5-2:temp stephen$ git clone ssh://bash@penguin/home/git/repos/test-repo.git
Cloning into test-repo...
warning: templates not found /Users/stephen/share/git-core/templates
remote: Counting objects: 100109, done.
remote: Compressing objects: 100% (23394/23394), done.
remote: Total 100109 (delta 76733), reused 99567 (delta 76231)
Receiving objects: 100% (100109/100109), 620.24 MiB | 28.36 MiB/s, done.
Resolving deltas: 100% (76733/76733), done.
snowg5-2:temp stephen$ cd test-repo
snowg5-2:test-repo stephen$ git checkout -b tmp origin/real-branch-name
Branch tmp set up to track remote branch real-branch-name from origin.
Switched to a new branch 'tmp'
... edit some files ...
snowg5-2:test-repo stephen$ git add -u .
snowg5-2:test-repo stephen$ git commit -m "made some changes"
[tmp 0440ace] made some changes
 1 files changed, 1 insertions(+), 0 deletions(-)
snowg5-2:test-repo stephen$ git push
Everything up-to-date
snowg5-2:test-repo stephen$ git rev-parse tmp
0440ace51b4ab18eee39305cd2af070f572e38d7
snowg5-2:test-repo stephen$ git ls-remote origin real-branch-name
92ebff3a7c332079bcbf84e9cf699ab635e6ba3c	refs/heads/real-branch-name
snowg5-2:test-repo stephen$ git --version
git version 1.7.3.2.g9027fa
snowg5-2:test-repo stephen$ 
Git doesn't push the change.  If I either use 
  a) git checkout --track origin/real-branch-name 
or
  b) git checkout -b real-branch-name origin/real-branch-name
the push succeeds.
Was the behavior of git push intentionally changed or is this a bug?

Thanks, Stephen

Next: Jeff King
Message 1 of 5 in “git push on tracking branches”
  1. Stephen BashSep 27, 2010
  2. Jeff KingSep 27, 2010
  3. Stephen BashSep 27, 2010
  4. NickSep 27, 2010
  5. Jeff KingSep 27, 2010

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.