A common scenario when I develop is that the codebase will have several config files which require machine specific settings. These files will be checked into Git and other
Building on @Greg Hewgill's answer, you could add a specific commit with your local changes and tag it as localchange:
git checkout -b feature master
vim config.local
git add -A && git commit -m "local commit" && git tag localchange
Then proceed to add your feature's commits. After finishing the work, you can merge this branch back to master without the localchange commit by doing this:
git rebase --onto master localchange feature
git fetch . feature:master
git cherry-pick localchange
git tag localchange -f
These commands will:
1) Rebase your feature branch to master, ignoring the localchange commit.
2) Fast forward master without leaving feature branch
3) Add localchange commit back to the top of the feature branch so you can continue working on it. You can do this to any other branch you want to continue working on.
4) Reset localchange tag to this cherry-picked commit so we can use rebase --onto
again in the same way.
This isn't meant to replace the accepted answer as the best general solution, but as a way of thinking out of the box about the problem. You basically avoid accidentally merging local changes to master by only rebasing from localchange
to feature
and fast forwarding master.