如何在github上上传项目可以参考的地址是:https://www.jianshu.com/p/08656eb84974
上传文件之后,如果不小心上传了公司的机密文件,可以使用以下的删除
git rm --cached test.py
git add .
git commit -m "删除文件"
git push
刷新下github,发现虽然文件删除了,但是在历史记录中还是有的,还可以点进去看文件,说明没有彻底删除
执行以下git命令,彻底删除文件
git filter-branch --force --prune-empty --index-filter 'git rm -rf --cached --ignore-unmatch test.py' --tag-name-filter cat -- --all
//force其实也是个很危险的操作 ,再执行以下代码之前,务必确保当前代码已经是最新,并且你开始操作后没有人提交过代码,
不然这么一force,有一大片冲突是必然的。。。
git push --force --all
刷新下,发现已彻底删除文件
具体详细的命令解释可以参考以下,写的很好
官方解释可以看这里:
https://git-scm.com/docs/git-filter-branch
https://git-scm.com/book/en/v2/Git-Tools-Rewriting-History
具体怎么使用可以参考这两篇博客:
http://harttle.com/2016/03/22/purge-large-files-in-gitrepo.html
http://blog.csdn.net/lwfcgz/article/details/49453375