-
Notifications
You must be signed in to change notification settings - Fork 141
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
00c3d22
commit 80ea9ef
Showing
1 changed file
with
29 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#!/bin/bash | ||
|
||
# Ensure git-filter-repo is installed | ||
if ! command -v git-filter-repo &> /dev/null | ||
then | ||
echo "git-filter-repo could not be found, please install it first." | ||
exit | ||
fi | ||
|
||
# Get a list of all files that were deleted at some point in history | ||
deleted_files=$(git log --diff-filter=D --summary | grep delete | awk '{print $NF}') | ||
|
||
# Loop through each deleted file | ||
for file in $deleted_files; do | ||
# Check if the file still exists in the current working directory | ||
if [ ! -f "$file" ]; then | ||
echo "Removing history of $file as it no longer exists..." | ||
# Remove history of the file using git filter-repo | ||
git filter-repo --path "$file" --invert-paths --force | ||
else | ||
echo "$file still exists, skipping history removal." | ||
fi | ||
done | ||
|
||
# Prompt the user to force-push the changes | ||
echo "History rewrite is complete." | ||
echo "To update the remote repository, run the following commands:" | ||
echo "git push origin --force --all" | ||
echo "git push origin --force --tags" |