Page Menu
Home
Sealhub
Search
Configure Global Search
Log In
Files
F10352572
git-remove-history
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
805 B
Referenced Files
None
Subscribers
None
git-remove-history
View Options
#!/bin/bash
set
-o
errexit
# Author: David Underhill
# Script to permanently delete files/folders from your git repository. To use
# it, cd to your repository's root and then run the script with a list of paths
# you want to delete, e.g., git-delete-history path1 path2
if
[
$#
-eq
0
]
;
then
exit
0
fi
# make sure we're at the root of git repo
if
[
!
-d
.git
]
;
then
echo
"Error: must run this script from the root of a git repository"
exit
1
fi
# remove all paths passed as arguments from the history of the repo
files
=
$@
git
filter-branch
--index-filter
"git rm -rf --cached --ignore-unmatch
$files
"
HEAD
# remove the temporary history git-filter-branch otherwise leaves behind for a long time
rm
-rf
.git/refs/original/
&&
git
reflog
expire
--all
&&
git
gc
--aggressive
--prune
File Metadata
Details
Attached
Mime Type
text/x-shellscript
Expires
Sun, Nov 2, 16:56 (13 h, 48 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1004830
Default Alt Text
git-remove-history (805 B)
Attached To
Mode
rS Sealious
Attached
Detach File
Event Timeline
Log In to Comment