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

Re: Local branch ahead of tracked remote branch but git push claims everything up-to-date

From
Michael J Gruber <michaeljgruber+gmane@fastmail.fm>
Date
Aug 22, 2008, 14:09 UTC
Message-ID
<g8mhag$i90$1@ger.gmane.org>
In-Reply-To
<1219337620037-740662.post@n2.nabble.com>
ir0s venit, vidit, dixit 21.08.2008 18:53:
Show 14 quoted lines
> Hi Michael,
> 
> Here are my results:
> 
> $ git ls-remote origin 
> 138ea08f9680a8def085b793c9cee70eed0e1f3b        HEAD
> 138ea08f9680a8def085b793c9cee70eed0e1f3b        refs/heads/master
> 75290a081feebcc4265825d017d9af07c7646951        refs/heads/remotebranch
> f11c723119cd9938e91e1ed5328ef143fb477f15        refs/heads/mybranch
> f11c723119cd9938e91e1ed5328ef143fb477f15        refs/heads/groups
> ...
> There are a few more
> 
> Is it the case that mybranch somehow became a remote branch?

It means that the repo "origin" has a branch called mybranch. From the sha1 and the one in your other mail (git ls-remote .) we see that it is identical with your local branch mybranch. It is most certainly the result of a command

git push origin mybranch

which (in the absence of any relevant lines in .git/config) just says that you push that branch into origin with the same name, creating a branch there if there's none. You can get rid of it using "git push origin :mybranch".

What you most probably wanted to do was
git push origin mybranch:remotebranch

which pushes your mybranch into the remotebranch of the origin repo. (You can put this in the config for later pushes, git config remote.origin.push mybranch:remotebranch).

On the other hand:
git push origin

only compares existing branches with matching names, which is why it reported "up to date".

On yet another hand (I'm losing count): When you switch to a tracking branch it is compared to its corresponding remote, and your mybranch and origin/remotebranch clearly differ:

Show 7 quoted lines
> Here are the results for this one: $ git log --pretty=oneline
> mybranch...origin/remotebranch 
> f11c723119cd9938e91e1ed5328ef143fb477f15 Merge branch 'remotebranch'
> of gitosis@sorry.must.obfuscate.url.com:my-repo into mybranch 
> eb41bd8f4f43d483b4a58bc98386c468bb69173c Ticket #1032 
> 5e76a7c9bce92519b308c031357794904bf0f4a6 Ticket #1038 
> cu5ceaf670c83f77c1b48e8d31a23456b744f1af0f Ticket #1044
Now, this
Show 10 quoted lines
> f11c723119cd9938e91e1ed5328ef143fb477f15         HEAD
> 138ea08f9680a8def085b793c9cee70eed0e1f3b        refs/heads/master
> 75290a081feebcc4265825d017d9af07c7646951        refs/heads/remotebranch
> f11c723119cd9938e91e1ed5328ef143fb477f15         refs/heads/mybranch
> 138ea08f9680a8def085b793c9cee70eed0e1f3b        refs/remotes/origin/HEAD
> 138ea08f9680a8def085b793c9cee70eed0e1f3b        refs/remotes/origin/master
> 75290a081feebcc4265825d017d9af07c7646951       
> refs/remotes/origin/remotebranch
> f11c723119cd9938e91e1ed5328ef143fb477f15        
> refs/remotes/origin/mybranch

from your other e-mail shows quite a zoo of branches you have locally now. Two of them should probably not be there:

refs/remotes/origin/mybranch is the result of fetching/pulling from origin after creating mybranch there by mistake.

refs/heads/remotebranch is a local branch named remotebranch. I don't know where it came from, but git revlog may tell you more.

As a word of comfort: I'm quite new to git and find things confusing sometimes, myself. But in the end I always found out that thinhs are the way they are for a good reason.

You're thinking of "two places" to exchange information for a branch,
which is natural and confused me first, too. But realise that for a sane
workflow you need three:
- remotebranch at the other repo origin,
- your remotes/origin/remotebranch which pulls from origin's repo, and -
your local tracking branch mybranch which pulls or rebases from
remotes/origin/remotebranch at the time of your chosing.

You push from mybranch into the remotebranch of the origin repo. That last one is the one that pushed you off ;) Seriously, that last leg of the workflow triangle is not setup automatically (because you may not have push access).

Cheers, Michael

Previous: ir0sNext: ir0s
Message 12 of 13 in “Local branch ahead of tracked remote branch but git push claims everything up-to-date”
  1. ir0sAug 20, 2008
  2. Alex RiesenAug 20, 2008
  3. Andreas FärberAug 20, 2008
  4. Avery PennarunAug 20, 2008
  5. Junio C HamanoAug 20, 2008
  6. Avery PennarunAug 20, 2008
  7. Daniel BarkalowAug 20, 2008
  8. Junio C HamanoAug 20, 2008
  9. ir0sAug 21, 2008
  10. Michael J GruberAug 21, 2008
  11. ir0sAug 21, 2008
  12. Michael J GruberAug 22, 2008
  13. ir0sAug 21, 2008

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.