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

Re: git push bug?

From
JHJan Hudec <bulb@ucw.cz>
Date
Oct 20, 2007, 12:05 UTC
Message-ID
<20071020120543.GA19521@efreet.light.src>
In-Reply-To
<000001c81280$ebc5c5e0$5267a8c0@Jocke>
On Fri, Oct 19, 2007 at 20:50:29 +0200, Joakim Tjernlund wrote:
Show 5 quoted lines
> On den 19 oktober 2007 19:25, Johannes Schindelin [mailto:Johannes.Schindelin@gmx.de] wrote:
> > It strikes me as really odd that you would _want_ to create a branch 
> > remotely, that has _never_ existed locally.
> It strikes me as really odd that a core developers like yourself
> hasn't tried to justify/explain why push works as it does.
Dscho it rarely kind to newbies.
Show 7 quoted lines
> As I am trying to convince our dev. group here to move to git instead of subversion, I
> need to learn how git works. Now I have gotten to the push function and I need
> to know what can be done with push and how, pitfalls too. As I go along I find behavior
> that I find odd and report these to the list.
> 
>  git push <repo> v2.6.23:refs/heads/linus
> will make a tag look like a branch

That's becasue tags come in two flavors -- annotated and unannotated. Annotated ones don't point to commits directly, but via 'tag' objects, that contain description and usually signature.

Now git push will simply assign a remote branch whatever value you give it. You gave it a tag, so it assigned a tag.

>  git push <repo> linus:linus
> won't let me create the remote branch linus but
>  git push <repo> linus
> will

Because in the former you are not saying whether refs/heads/linus, refs/tags/linus or something else (the fact that heads and tags are treated specially by git does not mean refs can't have other subdirectories -- it can).

On the other hand in the later it resolves the ref locally and uses the same name remotedly.

>  git push <repo> :linus
> OOPS, now I just deleted remote branch linus, no warning

Your commands are quite obvious. No need for warning. (Besides, isn't there a reflog?)

>  git push <repo> linus:refs/head/linus
> creates a branch that is invisible(wont show in git branch -a)
It does not create a branch. It creates a ref with slightly funny name (it's
refs/heads, not refs/head).
         ^
>  git push <repo> linus:refs/heads/newbranch
> creates remote branch newbranch, but you have to know the magic words
> refs/heads/ to do it.

Because you could have wanted a tag. Or a remote. Or something completely different, maybe because some add-on uses (eg. stgit uses refs/bases and refs/patches, IIRC).

> Se what I mean? 

To me it all looks perfectly consistent. But maybe the documentation should state more clearly, that push works in terms of arbitrary refs, NOT branches. Feel free to post a documentation patch (people who just had hard time finding something out are usually better at explaining it than old-timers who consider it obvious).

-- 
						 Jan 'Bulb' Hudec <bulb@ucw.cz>
Previous: Johannes SchindelinNext: Steffen Prohaska
Message 14 of 21 in “git push bug?”
  1. Joakim TjernlundOct 18, 2007
  2. Steffen ProhaskaOct 18, 2007
  3. Joakim TjernlundOct 18, 2007
  4. Joakim TjernlundOct 18, 2007
  5. Shawn O. PearceOct 19, 2007
  6. Steffen ProhaskaOct 18, 2007
  7. Johannes SchindelinOct 18, 2007
  8. Joakim TjernlundOct 18, 2007
  9. Johannes SchindelinOct 18, 2007
  10. Joakim TjernlundOct 19, 2007
  11. Johannes SchindelinOct 19, 2007
  12. Joakim TjernlundOct 19, 2007
  13. Johannes SchindelinOct 19, 2007
  14. Jan HudecOct 20, 2007
  15. Steffen ProhaskaOct 18, 2007
  16. Johannes SchindelinOct 18, 2007
  17. Steffen ProhaskaOct 20, 2007
  18. Steffen ProhaskaOct 20, 2007
  19. Joakim TjernlundOct 20, 2007
  20. Shawn O. PearceOct 19, 2007
  21. Joakim TjernlundOct 20, 2007

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.