Haisen大王:
restore () {
filepath="$@"
last_commit=$(git log --all --full-history -- $filepath | grep commit | head -1 | awk '{print $2; exit}')
echo "Restoring file from commit before $last_commit"
git checkout $last_commit^ -- $filepath
}
restore my/file_path
这个好,快捷解决了我的问题。
注意路径:my/file_path,是文件距离 项目根目录的 相对路径