我可以:
git-showlatest(){ git show $(git log -p -- "$1" |grep commit|head -n1|cut -d\ -f2):"$1"; }
作為 bash 函式。
有沒有更好的辦法?
uj5u.com熱心網友回復:
首先,您缺少插入符號 ( ^):
git-showlatest()
{
git show "$(git log -p -- "$1" |grep commit|head -n1|cut -d\ -f2)^:$1"
}
您需要插入符號,因為在相關修訂版中,該檔案不存在 - 因為它已被洗掉,所以您想要之前修訂版中存在的版本。
但正如@zedfoxus 所說,你不需要做這個決議(你也可以使用xargs):
git-showlatest()
{
git log -n 1 --pretty='format:%H' -- "$@" \
| xargs -I '{}' git show "{}^:$1"
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/483501.html
標籤:混帐
上一篇:Git隨機丟失跟蹤
