See all the commits for which searchstring appear in the git diff

git log -p -z | perl -ln0e 'print if /[+-].*searchedstring/'

1
By: takeshin
2010-06-13 07:41:22

These Might Interest You

  • A great command to assign to an alias, allowing you to git diff the last two commits in git.


    1
    git diff $(git log --pretty=format:%h -2 --reverse | tr "\n" " ")
    caffeinewriter · 2015-07-07 17:50:50 1

  • 0
    git diff --name-only --diff-filter=AMXTCR HEAD~2 HEAD | xargs -l -I{} cp --parents --verbose "{}" target_dir
    batandwa · 2013-02-11 08:12:40 0
  • Use find to recursively make a list of all files from the current directory and downwards. The files have to have an extension of the ones listed. Then for every file found, grep it for 'searchString', returns the filename if searchString is found. Show Sample Output


    -1
    find . -type f \( -name "*.js" -o -name "*.php" -o -name "*.inc" -o -name "*.html" -o -name "*.htm" -o -name "*.css" \) -exec grep -il 'searchString' {} \;
    niels_bom · 2010-02-07 15:28:20 0
  • Use this to make a new commit that "softly" reverts a branch to some commit (i.e. squashes the history into an inverse patch). You can review the changes first by doing the diff alone.


    4
    git diff HEAD..rev | git apply --index; git commit
    Pistos · 2009-02-06 17:29:46 0

What do you think?

Any thoughts on this command? Does it work on your machine? Can you do the same thing with only 14 characters?

You must be signed in to comment.

What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands



Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.

» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10

Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: