Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Another approach is to maintain local changes to common configuration files in another private branch. I do this for some projects that require several local changes. This technique may not be applicable to all situations, but it works for me in some cases.</p> <p>First I create a new branch based on the master branch (in this particular case I'm using git-svn so I need to commit from master but that's not terribly important here):</p> <pre><code>git checkout -b work master </code></pre> <p>Now modify the configuration file(s) as necessary and commit. I usually put something distinctive in the commit message like "NOCOMMIT" or "PRIVATE" (this will be useful later). At this point, you can work away on your private branch using your own config file.</p> <p>When you want to push your work back upstream, cherry-pick each change from your <code>work</code> branch to the master. I have a script to help do this, which looks something like this:</p> <pre><code>#!/bin/sh BRANCH=`git branch | grep ^\\* | cut -d' ' -f2` if [ $BRANCH != "master" ]; then echo "$0: Current branch is not master" exit 1 fi git log --pretty=oneline work...master | grep -v NOCOMMIT: | cut -d' ' -f1 | tac | xargs -l git cherry-pick </code></pre> <p>This first checks to make sure I'm on the <code>master</code> branch (sanity check). Then, it lists each commit in <code>work</code>, filters out the ones that mention the NOCOMMIT keyword, reverses the order, and finally cherry-picks each commit (now from the oldest first) into <code>master</code>. </p> <p>Finally, after pushing the changes in master upstream, I switch back to <code>work</code> and rebase:</p> <pre><code>git checkout work git rebase master </code></pre> <p>Git will reapply each of the commits in the <code>work</code> branch, effectively skipping over the one(s) that have already been applied in <code>master</code> through the cherry-picking. What you should be left with is only the NOCOMMIT local commits.</p> <p>This technique makes the push process a bit more time-consuming, but it solved a problem for me so I thought I'd share.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload