diff options
author | EuAndreh <eu@euandre.org> | 2024-11-18 08:21:58 -0300 |
---|---|---|
committer | EuAndreh <eu@euandre.org> | 2024-11-18 08:44:57 -0300 |
commit | 960e4410f76801356ebd42801c914b2910a302a7 (patch) | |
tree | 615d379416f72956d0c1666c63ce062859041fbe /src/content/tils/2020/08/16 | |
parent | Remove jekyll infrastructure setup (diff) | |
download | euandre.org-960e4410f76801356ebd42801c914b2910a302a7.tar.gz euandre.org-960e4410f76801356ebd42801c914b2910a302a7.tar.xz |
Diffstat (limited to 'src/content/tils/2020/08/16')
-rw-r--r-- | src/content/tils/2020/08/16/git-search.adoc | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/src/content/tils/2020/08/16/git-search.adoc b/src/content/tils/2020/08/16/git-search.adoc new file mode 100644 index 0000000..f3ae6f0 --- /dev/null +++ b/src/content/tils/2020/08/16/git-search.adoc @@ -0,0 +1,59 @@ +--- + +title: Search in git + +date: 2020-08-16 + +layout: post + +lang: en + +ref: search-in-git + +eu_categories: git + +--- + +Here's a useful trio to know about to help you search things in git: + +1. `git show <commit>` +2. `git log --grep='<regexp>'` +3. `git grep '<regexp>' [commit]` + +## 1. `git show <commit>` + +Show a specific commit and it's diff: + +```shell +git show +# shows the latest commit +git show <commit> +# shows an specific <commit> +git show v1.2 +# shows commit tagged with v1.2 +``` + +## 2. `git log --grep='<regexp>'` + +Search through the commit messages: + +```shell +git log --grep='refactor' +``` + +## 3. `git grep '<regexp>' [commit]` + +Search content in git history: + +```shell +git grep 'TODO' +# search the repository for the "TODO" string +git grep 'TODO' $(git rev-list --all) +# search the whole history for "TODO" string +``` + +And if you find an occurrence of the regexp in a specific commit and you want to +browse the repository in that point in time, you can +[use git checkout for that][0]. + +[0]: {% link _tils/2020-08-14-browse-a-git-repository-at-a-specific-commit.md %} |