Auto-update: Tue Jul 30 20:55:02 PDT 2024

This commit is contained in:
sanj 2024-07-30 20:55:02 -07:00
parent 30b6c49461
commit 7b89cb187c

33
gitpurge Executable file
View file

@ -0,0 +1,33 @@
#!/bin/bash
# Ensure we're in a git repository
if ! git rev-parse --is-inside-work-tree > /dev/null 2>&1; then
echo "Error: This script must be run inside a Git repository."
exit 1
fi
# Check if git-filter-repo is installed
if ! command -v git-filter-repo &> /dev/null; then
echo "Error: git-filter-repo is not installed. Please install it first."
echo "You can install it via pip: pip install git-filter-repo"
exit 1
fi
# Get a list of files that currently exist in the repository
current_files=$(git ls-files)
# Create a file with the list of files to keep
echo "$current_files" > files_to_keep.txt
# Use git-filter-repo to keep only the files that currently exist
git filter-repo --paths-from-file files_to_keep.txt --force
# Remove the temporary file
rm files_to_keep.txt
# Force push all branches
git push origin --all --force
echo "Purge complete. All files not present in the local repo have been removed from all commits on all branches."
echo "The changes have been force-pushed to the remote repository."