欧卡2中文社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

需要三步,才能开始

只需两步,慢速开始

玩欧卡就用莱仕达V10方向盘欧卡2入门方向盘选莱仕达V9莱仕达折叠便携游戏方向盘支架欢迎地图Mod入驻
查看: 4618|回复: 1
收起左侧

彻底删除git库中的文件

[复制链接]
oppo 发表于 2015-4-8 16:45 | 显示全部楼层 |阅读模式
代码如下:
[tex=code]
git filter-branch --index-filter 'git rm -r --cached --ignore-unmatch path/to/your/file' HEAD
git push origin master --force
rm -rf .git/refs/original/
git reflog expire --expire=now --all
git gc --prune=now
git gc --aggressive --prune=now
[/tex]
具体可以查看这篇文章 : http://help.github.com/remove-sensitive-data/

另外注意在多人协同工作时,防止其他人又将文件提交上来(如某些文件之前没有加入到.gitignore文件中,然后这个文件更改了),需要每个人执行上面除push外的其它代码,或者重新clone.
http://xuanyan.org/2011/12/20111204.html
 楼主| oppo 发表于 2015-4-8 16:46 | 显示全部楼层
当我们的 git repository 提交大的数据文件之后,.git 目录会很大,有时候有些数据我们已经不再需要,
这时候我们可以删除,但是没有彻底删除,.git 中会保存的有历史记录,这时候,我们可以用一下方式彻底删除。
[tex=code]
git filter-branch --index-filter \
    'git rm -r --cached --ignore-unmatch path/to/your/file' \
    HEAD
git push origin master --force
rm -rf .git/refs/original/
git reflog expire --expire=now --all
git gc --prune=now
git gc --aggressive --prune=now[/tex]
参考:

https://help.github.com/articles/remove-sensitive-data

This entry was written by zpz, posted on 2013 年 11 月 12 日 at 下午 5:27, filed under git and tagged git. Bookmark the permalink. Follow any comments here with the RSS feed for this post. Post a comment or leave a trackback: Trackback URL.

http://zpz.name/2287/

联系我们|手机版|欧卡2中国 ( 湘ICP备11020288号-1 )

GMT+8, 2024-4-26 03:38 , Processed in 0.031728 second(s), 8 queries , Redis On.

Powered by Discuz! X3.4

Copyright © 2001-2023, Tencent Cloud.

快速回复 返回顶部 返回列表