问题:
不小心把python scrapy项目里面一些不需要的目录,如所有pycache目录,提交远端,需要从git删除
调查:
https://stackoverflow.com/questions/7927230/remove-directory-from-remote-repository-after-adding-them-to-gitignore
https://git-scm.com/docs/gitignore
解决:
1
在项目根目录创建.gitignore文件
echo 123 > .gitignore
打开该文件,删除其中全部内容,保存。
找了一份现成的.gitignore
https://github.com/github/gitignore/blob/master/Python.gitignore
拷贝其中内容
粘贴到.gitignore
保存
在其中加上
**/__pycache__/
保存
2
unstage 不要的 pycache:
git rm -r --cache __pycache__
cd spiders
git rm -r --cache __pycache__
3
缓存修改
git commit -m "remove now ignored all cache dirs"
4
提交远端
git push origin master