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

Re: git-merge ignore specific files

From
Andreas Ericsson <ae@op5.se>
Date
Nov 6, 2007, 12:53 UTC
Message-ID
<473063C1.7070607@op5.se>
In-Reply-To
<174134.11501.qm@web55007.mail.re4.yahoo.com>
Bill Priest wrote:
Show 18 quoted lines
> All,
>   I have two branches that are slightly different and
> most changes "belong" in both.  There are a handful of
> files/directories that are disparate.  Is there any
> way in git to tell it not to merge these files?  Kind
> of like .gitignore but for merges.
>   In addition I'd like a way to specify to git-merge
> to leave all merged files unrecorded in the index. 
> Then as I go through each file making sure that the
> merge "makes sense" (not that git did the right thing;
> but that I want the changes in both branches) that I
> add the change to the index.
>   I'm sure that I'm probably using git "incorrectly"
> and I welcome suggestions for modifying my workflow to
> a git style.
> 
> Any and all suggestions greatly appreciated,
> 

At a cursory glance at the sources, it looks as if you should be able to get what you want with pretty small modifications to builtin-read-tree.c and git-merge.sh.

Specifically, 'git read-tree' (which does the heavy lifting during merges) takes --exclude-per-directory as an argument. You want to teach 'git merge' to do the same and pass that argument along to 'git read-tree'. Then it's just a matter of maintaining two sets of .gitignore files, one of which you'd probably want to call .mergeignore (or something) and make sure you don't forget to pass that option when you merge (although I assume you'd notice if you'd forgotten it during conflict resolution).

-- 
Andreas Ericsson                   andreas.ericsson@op5.se
OP5 AB                             www.op5.se
Tel: +46 8-230225                  Fax: +46 8-230231
Previous: Bill PriestNext: Jakub Narebski
Message 2 of 5 in “git-merge ignore specific files”
  1. Bill PriestNov 6, 2007
  2. Andreas EricssonNov 6, 2007
  3. Jakub NarebskiNov 6, 2007
  4. Bill PriestNov 6, 2007
  5. Jakub NarebskiNov 6, 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.