Can git ignore a specific line?

Viewed 46529

I'm using git to sync to phonegap while testing on the phone's native browser. As such I have the following line:

var isPhoneGap = false;

Obviously I change this when building, but is there any way I can set up git to ignore this one line or do I have to go and put it in its own file and ignore it that way?

I'm using Gitx and the terminal on OSX 10.6.

9 Answers

I think nobody has provided this way to work around the problem so, here's my technique. I keep logging/debugging/etc stuff in a single revision (actually, it could be multiple) in a private branch in my local repo. So, when I start a feature branch and I want to have all of my goodies (in my-goodies branch), I just do this:

git checkout my-feature
git cherry-pick my-feature..my-goodies # assuming both started from the same main branch, say, my-goodies started a few (or many) revisions back

Now I start working on the feature. When I am done, I rewrite history of the feature branch so that those revisions are gone:

git rebase -i @{u} # set all the goodies revisions to skip, save, and go

Now my branch is clean from all my goodies and I am fine to push anywhere.

Related