I have a file in a git repository that has a local change on it. I want to have git ignore the local change forever, but not the file. In particular,
- If the file isn't touched besides this change,
git add .
should never stage it. - Likewise,
git commit -a
shouldn't commit it. - If I ever make an additional change to the file, I should be able to stage and commit that change - but the change I'm ignoring should not be staged and committed.
Is there a way to do this? Doing some research, I read about "smudge/clean cycles," where, if I read correctly,
- the file would be marked as unchanged,
- the change I made would be overwritten when I checkout,
- and then a script would automatically reapply the change and then mark the file as unchanged again.
I am very new to git and scripting, though (I'm an intern with C# and Java experience), so if that's what I need to do, can you please post detailed directions or a link to a tutorial on how to set a smudge/clean cycle up?
Background: I want my working branch to be out of sync with the trunk. There is a low priority bug that only affects development machines, so rather than fix it, we're just commenting out the offending code. Obviously, we don't want this code to be removed from production, where it works just fine.
git add -p
. It's not automated, but you can add and commit changes to this file without a full blown solution. – Underdoggit help hooks
. There are lots of actions that you can hook where you could put your backup/restore commands. – Quintero