Question

Suppose that I have the follwoing folder structure:

My Project
    | - <project files>
    | - <project configuration files>

Every developer has different project configurations and wants to store these files on a separate branch.

It is then possible add these configurations into the branch you are working on by doing this:

# Get the configurations
git checkout jakesConfigurationFileBranch -- <project configuration files>

# Don't stage these files for commit
git reset -- <project configuration files>

Unfortionatly this workflow isn't working great because we have configuration files scattered accross our project (our project config files, Editor preferences, etc). IE:

My Project
    | - <project files with configuration files sprinkled throughout>

What I would really like to is merge in a branch without changing the history or staging the files.

git merge --files-Only jakesConfigurationFileBranch

Before running the command the tree would like like this:

          master
         /
*---*---*
 \
  *--* - jakesConfigurationFiles

And after the tree would look the same:

          master
         /
*---*---*
 \
  *--* - jakesConfigurationFiles

There is a flag called --no-commit on merge but it will perform a fast-foward merge so this doesn't always work (and won't block the pointer from being moved).

Was it helpful?

Solution 3

Doing this will work:

git merge --no-ff --no-commit devEnv-Jake 

Follow it up with:

git reset 

to clear the files from the staging area.


I actually created an alias to do this:

alias jake-mergeDevEnv-git='git merge --no-ff --no-commit devEnv-Jake ; git reset'

OTHER TIPS

My general recommendation is to keep a "dev" configuration file which will work for most developers and then override that using a per developer config file which is not version controlled or use environment variables.

One thing that may work for you is a simple script in your post-checkout hook to construct untracked localized configs from (tracked or untracked) per-branch substitutions, the hook's simple, and on checkout for every tracked fixmeup.@branch file it builds file fixmeup by including branch-specific content. It would be easy to modify this to do git show rather than cat to get your merge-from-repo effect.

Another way is to use filters to fix up content, the way that works is files marked with a filter attribute run your selected command to fix up the content in arbitrary ways on checkout and add. VonC has a good explanation linked to further good explanations for this.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top