Last active
April 5, 2018 18:45
-
-
Save kstevens715/ece63989a4e75f9a99921ab05fe7473f to your computer and use it in GitHub Desktop.
Git command to search history of a file for some text. This helps find when something was removed from a file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# Usage: | |
# To search for all occurrences in history of text "perform" in app/models/model.rb: | |
# | |
# git search-file-history perform app/models/model.rb | |
# | |
# TODO: A good future enhancement would be to show the commit right after the last occurrence, to see where it was removed. | |
# | |
text, filename = ARGV | |
puts `git grep #{text} $(git rev-list --all -- #{filename}) -- #{filename}` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment