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

Re: Merging submodules (was Re: Feature suggestion: git-hist)

From
Brian Gernhardt <benji@silverinsanity.com>
Date
Jul 30, 2008, 23:03 UTC
Message-ID
<20080730230336.GA6481@Hermes>
This message got eaten by a syntax error somewhere.  This is a re-send, sorry for any duplicate messages.
On Jul 30, 2008, at 12:26 PM, H.Merijn Brand wrote:
Show 24 quoted lines
> On Wed, 30 Jul 2008 11:15:55 -0400, Brian Gernhardt
> <benji@silverinsanity.com> wrote:
> 
> > Then you do something like:
> > 
> > rm -rf module_{a,b,c}/.git # Do this in a test repository, obviously...
> > git add module_a module_b module_c
> > git commit # Needed because '-s ours' uses current HEAD, not index
> 
> So far so good.
> 
> > git merge --no-commit -s ours module_a/master module_b/master module_c/master
> 
> $ git merge --no-commit -s ours fnc/master i00f000/master
> i99f000/master include/master l00m000/master l01f000/master
> l02f000/master l03f000/master l06f000/master l90z000/master
> leerpl/master mutbev/master prtabel/master rpt/master tabellen/master
> zoomen/master Automatic merge went well; stopped before committing as
> requested
> 
> > git commit --amend
> 
> $ git commit --amend
> fatal: You are in the middle of a merge -- cannot amend.

Hm. I did mention this was completely untested, yes? The problem comes from the fact that '-s ours' wants to use HEAD, not the index. But you can't amend a normal commit into a merge, apparently. And I don't think you want a commit that adds the files and a commit that "does the merge" as two separate steps.

Well, I don't know how to make the porcelain do this then. But the plumbing can definitely do it. Hopefully someone more used to doing strange things like this can give a simpler recipe, but this should work.

# First reset to the commit you made with all the modules added.
vim commit-message # Create a merge message
commit=$(git commit-tree HEAD: -p HEAD^ -p module_a/master -p
		module_b/master -p module_c/master < commit-message)
git update-ref HEAD $commit  # Update your current ref
~~ Brian
Next: H.Merijn Brand
Message 1 of 18 in “Re: Merging submodules (was Re: Feature suggestion: git-hist)”
  1. Brian GernhardtJul 30, 2008
  2. H.Merijn BrandJul 31, 2008
  3. H.Merijn BrandJul 31, 2008
  4. Petr BaudisJul 31, 2008
  5. H.Merijn BrandJul 31, 2008
  6. Santi BéjarJul 31, 2008
  7. H.Merijn BrandJul 31, 2008
  8. Santi BéjarJul 31, 2008
  9. H.Merijn BrandJul 31, 2008
  10. H.Merijn BrandAug 1, 2008
  11. Santi BéjarAug 1, 2008
  12. H.Merijn BrandAug 1, 2008
  13. Santi BéjarAug 1, 2008
  14. H.Merijn BrandAug 4, 2008
  15. Petr BaudisAug 4, 2008
  16. H.Merijn BrandAug 4, 2008
  17. Petr BaudisAug 4, 2008
  18. Santi BéjarJul 31, 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.