所以,假設我有兩個分支old_release(包含舊版本)和new_release(包含新版本)。在舊版本中有一個名為 的工具cook,我認為它仍然在新版本中,但它已被重命名。我需要弄清楚它被重命名為什么。
我想要一個必須滿足條件的檔案串列;
- 檔案同時存在于
old_release和new_release中。 - 字串
cook是在版本中找到的old_release。 cook從 的版本中找不到字串new_release。我需要這個條件,因為大部分代碼都沒有更新,并且將包含對cook.- 我的存盤庫很大,簽出一個分支需要很長時間。我想要一個避免這種情況的解決方案。
我目前的解決方案看起來像;
git checkout old_release
grep cook . -R -l -I > old_release_cooks.txt
sort -o old_release_cooks_sorted.txt old_release_cooks.txt
git checkout new_release
grep cook . -R -l -I > new_release_cooks.txt
sort -o new_release_cooks_sorted.txt new_release_cooks.txt
vim -d old_release_cooks_sorted.txt new_release_cooks_sorted.txt
除了第 4 點之外,這滿足了我的所有要求。它要求我至少進行一次結帳。嚴格來說,我猜它不會創建不同的檔案串列,但差異足夠接近。
有沒有辦法在不簽出的情況下獲取此串列?
uj5u.com熱心網友回復:
bash 中的無結帳單線,使用git grep并評估其結果comm:
word='cook' rel1='old_release' rel2='new_release'; comm -1 -2 <(comm -2 -3 <(git grep -l '\b'"$word"'\b' "$rel1" | sed 's/^[^:]*://' | sort;) <(git grep -l '\b'"$word"'\b' "$rel2" | sed 's/^[^:]*://' | sort;);) <(git grep -L '\b'"$word"'\b' "$rel2" | sed 's/^[^:]*://' | sort;)
編輯:調整以使您的條件 1. 也滿足(檔案必須同時存在)
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/461833.html
