From 020c1e77489b772f854bb3288b9c8d2818a6bf9d Mon Sep 17 00:00:00 2001 From: EuAndreh Date: Fri, 18 Apr 2025 02:17:12 -0300 Subject: git mv src/content/* src/content/en/ --- src/content/en/tils/2020/08/16/git-search.adoc | 49 ++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 src/content/en/tils/2020/08/16/git-search.adoc (limited to 'src/content/en/tils/2020/08/16') diff --git a/src/content/en/tils/2020/08/16/git-search.adoc b/src/content/en/tils/2020/08/16/git-search.adoc new file mode 100644 index 0000000..4113f3f --- /dev/null +++ b/src/content/en/tils/2020/08/16/git-search.adoc @@ -0,0 +1,49 @@ += Search in git +:categories: git + +Here's a useful trio to know about to help you search things in git: + +. `git show ` +. `git log --grep=''` +. `git grep '' [commit]` + +== 1. `git show ` + +Show a specific commit and it's diff: + +[source,sh] +---- +git show +# shows the latest commit +git show +# shows an specific +git show v1.2 +# shows commit tagged with v1.2 +---- + +== 2. `git log --grep=''` + +Search through the commit messages: + +[source,sh] +---- +git log --grep='refactor' +---- + +== 3. `git grep '' [commit]` + +:browse-article: link:../14/browse-git.html + +Search content in git history: + +[source,sh] +---- +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 {browse-article}[use git +checkout for that]. -- cgit v1.2.3