一个找回 git 未提交代码的 shell 脚本
#RePost #Script #GitHub
https://gist.github.com/bestK/bf56d7fc20f10daae692c5c9450476a9
https://www.v2ex.com/t/1027406#reply0
Message link`
#RePost #Script #GitHub
https://gist.github.com/bestK/bf56d7fc20f10daae692c5c9450476a9
#!/bin/bash #@author liukl # 设置要搜索的目录 search_dir="/path/to/your_project/.git/objects" # 切换到当前目录 cd "$search_dir" # 列出当前目录下的所有子目录 for dir in *; do cd $search_dir/$dir for file in *; do # 确保当前项目是文件 if [ -f "$file" ]; then filename=$(basename "$file") filepath="$dir$filename" content=$(git cat-file -p "$filepath") echo "$content" >> ../找回文件.txt fi done # 返回上一级目录 cd .. done yes "-" | sed '102q' | tr -d "\n" && echo echo Done!
https://www.v2ex.com/t/1027406#reply0
Message link`