Created
October 1, 2020 05:32
-
-
Save avioli/0e2bc80ee189f0b3cfce1add600037c3 to your computer and use it in GitHub Desktop.
Packages all current commits into a tar.gz archive and deletes all git tracked files (beware - deletes empty and untracked dirs, but leaves untracked files)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
git diff --name-status --exit-code >/dev/null | |
[[ "$?" == "1" ]] && { echo " --- found uncommited changes"; exit 1; } | |
echo "removing all git files and packaging .git dir into an archive" | |
set -e | |
git ls-files | while read f; do test -f "$f" && echo "$f"; done | xargs -n 30 -- rm -f | |
find . -type d -empty -delete | |
tar czf bare.tar.gz .git | |
rm -rf .git | |
echo "#!/bin/bash" > revive.sh | |
echo "set -e" >> revive.sh | |
echo "tar xf bare.tar.gz && git reset --hard" >> revive.sh | |
echo "rm bare.tar.gz revive.sh" >> revive.sh | |
chmod u+x revive.sh | |
echo "done. run ./revive.sh to reverse the process" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment