On my local branch, I have some personal (local-only) changes to a Makefile (just changing the path to the compiler). Obviously I don’t want to commit those changes in as they are only relevant to me. However, if I don’t commit them then I get an error when I try to sync with the remote branch:
% git fetch upstream
% git merge upstream/master
error: Your local changes to 'Makefile' would be overwritten by merge. Aborting.
Please, commit your changes or stash them before you can merge.
Stashing and then un-stashing the file every time this happens seems tedious. On Perforce for example, you would just move those file(s) to a separate change list and resolve merge conflicts where necessary.
What I want to happen is for git to automatically merge my local Makefile with the remote one (where possible), but without having to commit it. How would I got about doing that?
There are likely several ways to approach this problem, here’s my thought.
Make a new
makefixbranch and commit the makefile there. Whenever you need to make the project, switch to that branch. You can work inmasterand just keep merging, or rebasing themakefixbranch againstmaster.The general idea is that you’re creating a branch containing your
Makefilethat is never pushed.Personally I would rebase
makefixagainstmasterso myMakefilechanges always stayed ahead of the actual pushable code. It just feels cleaner in my head.Code Example
Make your changes to
MakefileFor every-day work
It’s long and ugly, so I hope someone else has a better way =]