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

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

From
Junio C Hamano <gitster@pobox.com>
Date
Feb 18, 2009, 01:05 UTC
Message-ID
<7v1vtw367w.fsf@gitster.siamese.dyndns.org>
In-Reply-To
<e38bce640902171649g765275a4n4e86d1d4f4aaf394@mail.gmail.com>
Brent Goodrick <bgoodr@gmail.com> writes:
Show 14 quoted lines
> 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.
You would have one common branch and one branch per deployment.

A common branch would host only common files (e.g. generic.sh file from your example). Per deployment branch, e.g. home, would branch from the common branch (so it starts with some version of generic.sh) and may add its own private files (e.g. home.sh).

And stick to the following two rules:
 - You make edits to common files only on the common branch.
 - You merge from common to deployment, never the other way.

So at work, you would have a checkout of your work "deployment branch", and find needs to change things. It is Ok to edit both work.sh and generic.sh (without being able to edit both, it would be hard to verify if the changes would work together) at this time, but don't commit the result in the work branch.

Save the changes to work.sh away (e.g. "git diff work.sh >P.diff" and then "git checkout HEAD work.sh"), switch to the common branch, and commit the changes to the generic file. Switch back to the deployment branch, merge the common branch (to pick up the changes to home.sh), reapply the changes specific to the deployment you saved earlier (e.g. "git apply P.diff"), tne commit the result.

Previous: Brent GoodrickNext: Brent Goodrick
Message 2 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.