From 2a4e1419a2543901495f8720590c3c5d2d612e1b Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Thu, 21 Mar 2013 15:34:53 -0400 Subject: [PATCH] git-grepall.sh: Add a script for grepping all local branches Sometimes I have a lot of branches (e.g. per-assignment branches for a single class, to support sharing work between assignments), and I forget which feature is in which branch. Now I can run: $ git-grepall.sh PATTERN to search all the local branches. --- posts/Git/git-grepall.sh | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100755 posts/Git/git-grepall.sh diff --git a/posts/Git/git-grepall.sh b/posts/Git/git-grepall.sh new file mode 100755 index 0000000..2038946 --- /dev/null +++ b/posts/Git/git-grepall.sh @@ -0,0 +1,24 @@ +#!/bin/sh +# +# Copyright (C) 2013 W. Trevor King +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this program. If not, see +# . + + +PATTERN="$1" +shift +for BRANCH in $(git branch --no-color --no-column | grep -v '\*'); do + git --no-pager grep "$PATTERN" "$BRANCH" -- "$@" +done -- 2.26.2