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

From: Brent Goodrick <hidden>
Date: 2016-06-15 22:46:13

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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help