交互式爱情
我建议这个剧本大卫·安德希尔的作品,对我来说很有魅力。此外,它还添加了这些命令,以清理它留下的混乱:rm -rf .git/refs/original/git reflog expire --all
git gc --aggressive --prune完整脚本(全归功于大卫·安德希尔)#!/bin/bashset -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
path2if [ $# -eq 0 ]; then
exit 0fi# make sure we're at the root of git repoif [ ! -d .git ]; then
echo "Error: must run this script from the root of a git repository"
exit 1fi# remove all paths passed as arguments from the history of the repofiles=$@
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 timerm -rf .git/refs/original/ && \
git reflog expire --all && \
git gc --aggressive --prune如果将最后两个命令更改为以下命令,可能会工作得更好:git reflog expire --expire=now --all && \
git gc --aggressive --prune=now