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,
git add .
should never stage it.git commit -a
shouldn't commit it.Is there a way to do this? Doing some research, I read about "smudge/clean cycles," where, if I read correctly,
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.
As I see it, the situation you are describing is this: you want to maintain a working directory that is different from the local repository.
This is not advisable; because these changes are not committed you will have little recourse if a file is accidentally deleted or changed in a way you do not want.
Therefore it is recommended that you in fact commit all your changes. If you would like to separate these changes you can easily do that using a branch. Example
git checkout -b new-branch
# now you can change the file without affecting master
echo bar >> foo
git add
git commit
# and back to master
git checkout master