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

Is there a way to exclude user-specified files or directories from participating in merges?

From
Brent Goodrick <bgoodr@gmail.com>
Date
Feb 18, 2009, 00:49 UTC
Message-ID
<e38bce640902171649g765275a4n4e86d1d4f4aaf394@mail.gmail.com>

Suppose I create a git repo called central.git on a machine I will call "central". In that central.git repo, I put these files:

  work.sh
  home.sh
  generic.sh

When I clone the central.git repo on to a different machine I will call "work", I want this fileset to be pulled:

  work.sh
  generic.sh
But not the home.sh file.

Similarly, when I clone the central.git repo on a machine I will call "home", I want this fileset to be pulled:

  home.sh
  generic.sh
But not the work.sh file.

What I think I need are two branches, one called "home_branch" and "work_branch", but read on for the twist:

Say I'm working on editing the work machines fileset on the work repo I had cloned originally from central.git, and commit a change to both generic.sh and work.sh. I do a git-push to an appropriate remote branch I have set up on the central.git repo, so that I can do a git-merge type of integration on the central machine in the central.git repo into the other branches (i.e., into the home_branch), specifically so that the home_branch gets updated with the change to the generic.sh file. However, I want the home_branch to be updated with the change I made to generic.sh, but I don't ever want the work.sh to show up in the home_branch that would occur during a normal merge. Likewise, I would not ever want the home.sh file to participate in merges from the work fileset back over to the home fileset (and likewise I would not ever want to see the work.sh file show up on the home_branch).

The above should apply for all files certain special directories. For instance, if I were to have a work_files directory and a home_files directory, then the the work_files is for the "work" machine (and work_branch) and the "home_files" is for the "home" machine (and home_branch).

How do I mark certain files and/or directories (via relative file paths or with file globbing) on certain branches to be excluded from being merged into all other (or a specified list of) branches? Ideally I would want to only have to add some logic to the .git/config file in the central.git repo that specifies the exclusions/exceptions, and not have to remember to make corresponding changes into any of the other repos that are cloned from it. Is this possible?

Also, is there a way to avoid the home.sh file from ever being added to any file underneath the .git directory of the repo I cloned on the "work" machine. I would not want there to be any risk that anyone with network access to the "work" machine (say, a sysadmin with sufficient privileges) to be able to see any form of the home.sh file since it exists on some branch in the .git directory.

Thanks, Brent

Next: Junio C Hamano
Message 1 of 9 in “Is there a way to exclude user-specified files or directories from participating in merges?”
  1. Brent GoodrickFeb 18, 2009
  2. Junio C HamanoFeb 18, 2009
  3. Brent GoodrickFeb 18, 2009
  4. Junio C HamanoFeb 18, 2009
  5. Brent GoodrickFeb 18, 2009
  6. Junio C HamanoFeb 18, 2009
  7. Sitaram ChamartyFeb 18, 2009
  8. Junio C HamanoFeb 18, 2009
  9. Sitaram ChamartyFeb 19, 2009

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.