cat /tmp/commit_list | { while read old_commit ; do msg="`git log --pretty=oneline $old_commit'^'..$old_commit | sed 's/[0-9a-f]* //' | sed 's/[^A-Za-z0-9]/./g'`"; git log --pretty=oneline HEAD@'{100}'..HEAD | grep "$msg" ; done ; }

find git commits by description

Given a file with the format of 'git log --pretty=short', search in last 100 commits for one with the same description. I used this when after a rebase I had to find out the new commit ids. The second sed replaces all special characters with dots so they don't mess up the grep later on.
Sample Output
0dd4c64aa728a398d2c579868a3f0191f5d3b4fa write some awesome feature
9a26d4a9a2e37a68dbf21619ef03b58017a42f2f fix a nasty bug
04dcc29359e95e5b944d634cff307605f7c573df write another cool feature

By: plexus
2012-10-11 11:06:40

These Might Interest You

  • My script lists all users & the number of commits they made in the period, sorted alphabetically. To sort by number of commits, append a '|sort' to the end of the command. The script depends on the output format of svn log - original command didn't work for me because the string 'user' was not appearing in my output

    svn log -r{2011-08-01}:HEAD|awk '$14 ~/line/ {print $3}'|sort|uniq -c
    sangnoir · 2011-09-01 07:58:54 0
  • A great command to assign to an alias, allowing you to git diff the last two commits in git.

    git diff $(git log --pretty=format:%h -2 --reverse | tr "\n" " ")
    caffeinewriter · 2015-07-07 17:50:50 1
  • Outputs a quick summary of the svn commits for a user over a date range with the detail revision logs including comments and files affected. Useful for searching for a particular change or reporting by user. Show Sample Output

    for i in `svn log -r{2011-02-01}:HEAD | awk '$3 == "user" {print $1}'`; do svn log -v -$i;done
    vijayphadke · 2011-03-04 17:11:22 0
  • Use this command to find out a list of committers sorted by the frequency of commits. Show Sample Output

    svn log -q|grep "|"|awk "{print \$3}"|sort|uniq -c|sort -nr
    psytek · 2009-02-17 21:37:03 1

  • -1
    xe vm-copy vm="ABCServer" sr-uuid=24565487-accf-55ed-54da54993ade784a new-name-label="Copy of ABCServer" new-name-description="New Description"
    layer8 · 2010-09-28 18:23:56 0
  • This lengthy cryptic line will print the latest top 10 posts without their summaries. To print also their respective summaries use the following (even bigger) command line: wget -qO - | xmlstarlet sel -T -t -o '<doc>' -n -t -m rss/channel/item -o '<item>' -n -o '<title>' -v title -o '</title>' -n -o '<description>' -v description -o '</description>' -n -o '</item>' -n -t -o '</doc>' | xmlstarlet sel -T -t -m doc/item -v description/code -n -v title -n -n It is recommended to include this line into a shell script to be easily run, as I do myself. You could also use the following URLs to browse the top 3 commands: wget -qO - | xmlstarlet ... .. or all others: wget -qO - | xmlstarlet ... PS: You need to install "xmlstarlet" to run it. It is found in Debian APT repositories (apt-get install xmlstarlet) or under the URL. Show Sample Output

    wget -qO - | xmlstarlet sel -T -t -o '&lt;x&gt;' -n -t -m rss/channel/item -o '&lt;y&gt;' -n -v description -o '&lt;/y&gt;' -n -t -o '&lt;/x&gt;' | xmlstarlet sel -T -t -m x/y -v code -n
    fsilveira · 2009-08-14 02:44:00 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? 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.


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: