Git seems to always have the feature I need, but often I’m not able to find it right away. While searching for a commit where a certain constant had been removed, I stumbled upon the deprecated git-diff-grep, which, in its readme, led me to the solution I could have easily found by just reading the, you know, manual (i.e.
man git-log) :)
Look for differences that introduce or remove an instance of
<string>.Note that this is different than the string simply
appearing in diff output; see the pickaxe entry in gitdiffcore(7)
for more details.
Look for differences whose added or removed line matches the given
Knowing that, you can simply do the following:
$ git log -S"WHERE_DID_IT_GO"
$ git log -G"WHERE_DID.*"
If you want to see the commit’s diff as well, just supply the
I usually work with a tab width of 4 when editing code, but
git-diff (that is the *nix
less program) seems to use a default tab width of 8. You can change this behavior by setting the
core.pager option to something like this:
This would result in a tab width of 4. If you are not familiar with git config, here’s how you set the option:
$ git config --global core.pager 'less -x4'
If you remove the
--global flag, the option will be changed only for the current git repository, otherwise it will be changed globally for the current user account.
I’ve been there a lot: I’m using some kind of existing framework / tool / open source software which is awesome, but there is that tiny little thing that annoys me, and I’d like to change it.
This guide is based on the Ubuntu Installation Guide from the Gitorious Wiki, but it is a little outdated, so here’s my updated version.