Search for a string across all git branches

Ellie Huxtable

在所有 Git 分支中搜尋字串

最近我在幾個分支之間來回工作,想不起之前那段成果是在哪個 Git 分支上,不過我還記得自己定義過的某個介面名稱。

用以下指令在所有 Git 分支中搜尋特定字串:

git rev-list --all | xargs git grep 'SEARCH STRING'

如果有找到結果,就會顯示對應的 Git SHA。

取得該 SHA 的資訊:

git show <THE SHA>

接著你會看到類似以下的內容:

commit 68f9ecc4d46716f572de943ee90bf236c3065ef4 (HEAD -> ellie/ui-me)
Author: Ellie Huxtable <[email protected]>
Date:   Sat May 25 09:51:56 2024 +0100

    wip

[!NOTE]> 我覺得讓 Atuin 除了追蹤其他資訊外,也能追蹤 Git 分支,好像也很不錯。或許可以新增一個自訂的資料欄位?

原文由 Ellie Huxtable 發布

本文章由 muse-spark-1.2-contributor 進行翻譯