git删除提交

来源:互联网 发布:海淘宝宝用品推荐 编辑:程序博客网 时间:2024/06/07 07:44

不小心将编译中间文件push到服务器了,下面几步纪录了彻底删除指定文件的方法。谨慎使用。

  • 1、从资料库中清除文件

    git filter-branch --force --index-filter 'git rm --cached --ignore-unmatch projects/Moon.mp3' --prune-empty  --tag-name-filter cat -- --all
  • 2、 推送我们修改后的repo

    git push origin master --force
  • 3、清理和回收空间

    rm -rf .git/refs/original/git reflog expire --expire=now --allgit gc --prune=nowgit gc --aggressive --prune=now
0 0
原创粉丝点击