Monday, September 10, 2012

When was a line added to a file - git bisect + grep

When do you want to know in which commit was a text added into a file, here are steps for bash + grep + git

export TEXT_TO_SEARCH="jcr.fetch.delay"
export FILE="portal-impl/src/portal.properties"

git bisect start "$FILE"
git bisect bad
git bisect good `git rev-list --parents HEAD "$FILE" | egrep "^[a-f0-9]{40}$"`

while
    ((grep "$TEXT_TO_SEARCH" "$FILE" > /dev/null && git bisect bad) || git bisect good) | grep Bisecting
do
    continue
done

git bisect visualize

git bisect reset

No comments:

Post a Comment