Skip to content

Instantly share code, notes, and snippets.

@cnjimbo
Last active September 5, 2023 07:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cnjimbo/169bc8b3d4d16eb405c2b04939a8129c to your computer and use it in GitHub Desktop.
Save cnjimbo/169bc8b3d4d16eb405c2b04939a8129c to your computer and use it in GitHub Desktop.
sh gists
#!/bin/bash
# 循环子目录,收缩git目录。清理历史记录,删除未引用提交,
# 并执行git reset --hard
for dir in */; do
cd "$dir"
if [ -d .git ]; then
echo "Resetting $dir"
git reset --hard
git prune
git gc
git clean -xfd
fi
cd ..
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment