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

confusion over the new branch and merge config

From
Nicolas Pitre <nico@cam.org>
Date
Dec 21, 2006, 22:17 UTC
Message-ID
<Pine.LNX.4.64.0612211555210.18171@xanadu.home>

OK I know I'm a total idiot and honnestly I didn't look at the code implementation at all because I don't expect newbies to even look there.

But here's some pitfalls I'm sure people are likely to encounter...
$ git clone git://git.kernel.org/pub/scm/git/git.git git
Initialized empty Git repository in /home/nico/test/git/.git/
remote: Generating pack...
remote: Done counting 34527 objects.
remote: Deltifying 34527 objects.
remote:  100% (34527/34527) done
Indexing 34527 objects.
remote: Total 34527, written 34527 (delta 23920), reused 34111 (delta 23623)
 100% (34527/34527) done
Resolving 23920 deltas.
 100% (23920/23920) done
Checking files out...
 100% (748/748) done
[ wooh! I feel good ]
$ cd git
$ git branch
* master
[ Hmmm... there used to be many more (remote) branches before.  Where 
  are they? Looking into .git/refs I see a remote/ directory and all 
   remote branches are there.  But I'm cheating now because a newbie 
   might not even think of looking there.
   Ah? there is -a and -r options to git-branch.  Fair enough. ]
$ git branch -r
* master
  origin/HEAD
  origin/html
  origin/maint
  origin/man
  origin/master
  origin/next
  origin/pu
  origin/todo
$ git checkout next
error: pathspec 'next' did not match any file(s) known to git.
Did you forget to 'git add'?
[ WTF!?!?  This definitely used to work before.  OK it is listed as
  "origin/next" so let's try to be consistent. ]
$ git checkout origin/next
git checkout: to checkout the requested commit you need to specify
              a name for a new branch which is created and switched to
[ Hmmmmmmmm.... /me stares at the message wondering.
  I just want to _see_ and maybe _install_ the code from "next". ]

$ git checkout origin/next local_next error: pathspec 'local_next' did not match any file(s) known to git. Did you forget to 'git add'?

[ But it just said to me above that I needed to provide a name for the 
  branch to be switched to...  Why doesn't it just work? F***ing tool!
  OK I'll use my git knowledge and cheat again. ]
$ git checkout -b local_next origin/next

This is I think a good example where user experience might still be improved. First the message about "providing a name for a new branch" could certainly be less anbigous.

Then the "next" branch name could possibly be made to work without the "origin/" if there is no conflict?

And there was a discussion about allowing checkouts to be made from a remote branch but not allowing any commit on it. What happened of this idea?

Now that I have my local_next branch, I want it to be kept up to date when performing a pull. Before the "next" branch sort of was always updated, but now it is a separate thing I cannot see directly and I need to pull it in my local version.

$ git pull origin/next fatal: The remote end hung up unexpectedly Cannot get the repository state from git://git.kernel.org/pub/scm/git/git.git/next

[ WTF?  Where that ...pub/scm/git/git.git/next comes from?  Hmmm... ]

$ git pull next fatal: 'next': unable to chdir or not a git archive fatal: The remote end hung up unexpectedly Cannot get the repository state from next

[ ... an even more interesting set of error messages.
  Yeah, Linus says you must use git-pull . blah syntax. ]

$ git pull . next error: no such remote ref refs/heads/next Fetch failure: . $ git pull . origin/next error: no such remote ref refs/heads/origin/next Fetch failure: .

[ F**K YOU STUPID TOOL !!!  OK let's cheat a bit again. ]

$ git pull . remotes/origin/next Already up-to-date.

[ Woooh!  But since I always hated this syntax let's try merge instead. ]

$ git merge origin/next Already up-to-date.

OK here again various error messages could be improved. The fact that a remote connection was established in some cases is really dubious. And git-pull not accepting "origin/next" is IMHO a bug.

Well well... But I don't want to perform this two-step git-pull+git-merge all the time. So let's have a look at this promising warning:

$ git pull origin
Warning: No merge candidate found because value of config option
         "branch.local_next.merge" does not match any remote branch fetched.
No changes.

So this means that branch.local_next.merge should be set to origin/next? Let's have a look at the default in .git/config:

[remote "origin"]
        url = git://git.kernel.org/pub/scm/git/git.git
        fetch = refs/heads/*:refs/remotes/origin/*
[branch "master"]
        remote = origin
        merge = refs/heads/master

But according to the warning above, branch.master.merge should have been set to refs/remotes/origin/master, not refs/heads/master, right? Otherwise does this mean that master will merge itself into itself?

This is where my own git experience stops as I don't understand the above for real. So let's see the doc:

|branch.<name>.merge::
|        When in branch <name>, it tells `git fetch` the default refspec to
|        be marked for merging in FETCH_HEAD. The value has exactly to match
|        a remote part of one of the refspecs which are fetched from the remote
|        given by "branch.<name>.remote".
|        The merge information is used by `git pull` (which at first calls
|        `git fetch`) to lookup the default branch for merging. Without
|        this option, `git pull` defaults to merge the first refspec fetched.
|        Specify multiple values to get an octopus merge.

Hmmmmmmm... Even after reading this twice I'm still not sure what it really means. But as I said at the top I'm an idiot.

Nicolas
Next: Junio C Hamano
Message 1 of 45 in “confusion over the new branch and merge config”
  1. Nicolas PitreDec 21, 2006
  2. Junio C HamanoDec 21, 2006
  3. SeanDec 21, 2006
  4. Junio C HamanoDec 22, 2006
  5. Junio C HamanoDec 22, 2006
  6. SeanDec 22, 2006
  7. Andy ParkinsDec 22, 2006
  8. Alan ChandlerDec 22, 2006
  9. Junio C HamanoDec 22, 2006
  10. Andy ParkinsDec 22, 2006
  11. Alan ChandlerDec 22, 2006
  12. Nicolas PitreDec 22, 2006
  13. Jakub NarebskiDec 22, 2006
  14. Nicolas PitreDec 22, 2006
  15. Jakub NarebskiDec 22, 2006
  16. Junio C HamanoDec 22, 2006
  17. Tom PrinceDec 23, 2006
  18. Nicolas PitreDec 23, 2006
  19. Jeff KingDec 23, 2006
  20. Nicolas PitreDec 23, 2006
  21. Junio C HamanoDec 23, 2006
  22. Shawn PearceDec 23, 2006
  23. Jeff KingDec 23, 2006
  24. Junio C HamanoDec 23, 2006
  25. Jeff KingDec 23, 2006
  26. Junio C HamanoDec 23, 2006
  27. Jakub NarebskiDec 23, 2006
  28. Johannes SchindelinDec 23, 2006
  29. Jakub NarebskiDec 23, 2006
  30. Jeff KingDec 24, 2006
  31. Nicolas PitreDec 24, 2006
  32. Jeff KingDec 26, 2006
  33. Jeff KingJan 2, 2007
  34. Junio C HamanoJan 2, 2007
  35. Jeff KingJan 2, 2007
  36. Junio C HamanoJan 2, 2007
  37. Jakub NarebskiJan 2, 2007
  38. Santi BéjarJan 3, 2007
  39. Jakub NarebskiJan 3, 2007
  40. Jeff KingJan 9, 2007
  41. Jeff KingJan 9, 2007
  42. Jakub NarebskiDec 23, 2006
  43. Andy ParkinsDec 22, 2006
  44. Lars HjemliDec 22, 2006
  45. Nicolas PitreDec 22, 2006

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.