git 如何清理操作日志_从Git历史记录中删除敏感文件及其提交

c4e5aa70a606355b76598f7d423fd6bb.png

交互式爱情

我建议这个剧本大卫·安德希尔的作品,对我来说很有魅力。此外,它还添加了这些命令,以清理它留下的混乱: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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值