mirror of
https://github.com/kuaifan/dootask.git
synced 2025-12-13 12:02:51 +00:00
Remove file '/public/js/build' from history
This commit is contained in:
parent
d167efb52b
commit
cfb8818f7b
1
.gitignore
vendored
1
.gitignore
vendored
@ -26,3 +26,4 @@ laravels-timer-process.pid
|
||||
vars.yaml
|
||||
laravels.conf
|
||||
laravels.pid
|
||||
**//public/js//public/js/build
|
||||
|
||||
36
rewrite-history.sh
Normal file
36
rewrite-history.sh
Normal file
@ -0,0 +1,36 @@
|
||||
#!/bin/bash
|
||||
|
||||
# 用于删除历史纪录中指定文件的脚本
|
||||
|
||||
# 确认用户输入参数
|
||||
if [ $# -ne 1 ]
|
||||
then
|
||||
echo "Usage: rewrite-history.sh <file-to-remove>"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# 获取文件名和目录路径
|
||||
file_to_remove=$1
|
||||
dir_path=$(dirname "${file_to_remove}")
|
||||
|
||||
# 移动到 Git 根目录
|
||||
cd $(git rev-parse --show-toplevel)
|
||||
|
||||
# 移除指定文件
|
||||
git filter-branch --force --index-filter "git rm --cached --ignore-unmatch ${file_to_remove}" --prune-empty --tag-name-filter cat -- --all
|
||||
|
||||
# 删除备份文件
|
||||
rm -Rf .git/refs/original/
|
||||
|
||||
# 清理垃圾文件
|
||||
git reflog expire --expire=now --all && git gc --prune=now --aggressive
|
||||
|
||||
# 重置 Ignored 文件
|
||||
echo "**/${dir_path}/${file_to_remove}" >> .gitignore
|
||||
|
||||
# 提交更改并强制推送到远程仓库
|
||||
git add .
|
||||
git commit -m "Remove file '${file_to_remove}' from history"
|
||||
git push origin --force --all
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user