Skip to content

Instantly share code, notes, and snippets.

@stopanko
Last active March 13, 2019 13:58
Show Gist options
  • Save stopanko/2752227aa3c6fb80b8d47b7be2d733a4 to your computer and use it in GitHub Desktop.
Save stopanko/2752227aa3c6fb80b8d47b7be2d733a4 to your computer and use it in GitHub Desktop.
Git commands
# Search commits by content in the files
## By default, git grep will look through the files in your working directory.
### This grep commant will output the files in the current directory that contains the gmtime_r inside(Doesnt' matters when this changes was made)
git grep -n gmtime_r
## If you want to know the commint when the changes was introduces you should use git log command
git log -S "Text that was added/deleted in the commit"
## If you want to see the changelog instead pf just commits list use -p option
git log -p -S "Upcoming Travel"
## you can use regular expression
git log -p -G "Upcoming (Travel|Trip)"
## Another fairly advanced log search that is insanely useful is the line history search.
git log -L :git_deflate_bound:zlib.c
## If Git can’t figure out how to match a function or method in your programming language, you can also provide it with a regular expression (or regex)
git log -L '/unsigned long git_deflate_bound/',/^}/:zlib.c
## To search the commit log (across all branches) for the given text:
git log --all --grep='Build 0051'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment