自学内容网 自学内容网

git忽略python项目中的__pycache__目录

一:编写.gitignore文件

# 忽略 tensorone-storage-log/ 目录
tensorone-storage-log/

# 忽略 file_test 目录
file_test/

# 忽略 .idea 目录
/.idea

# 忽略 .vscode 目录
.vscode

# 忽略 __pycache__ 目录及其所有子内容
**/__pycache__/

二:提交更改,推送分支

$ git add .

$ git commit -m 'style:.gitignore add ignore __pycache__/'

$ git push origin dev


三:如果发现没生效,说明 __pycache__ 目录下的文件已经被 Git 跟踪,它们会继续存在于版本控制中。需要从 Git 索引中移除

(1)git删除所有索引

$ git rm -r --cached .

(2)重新添加所有文件到索引中,根据更新后的 .gitignore 规则

$ git add .

(3)重新提交并推送,发现这次可以了


原文地址:https://blog.csdn.net/qq_41905051/article/details/142586981

免责声明:本站文章内容转载自网络资源,如本站内容侵犯了原著者的合法权益,可联系本站删除。更多内容请关注自学内容网(zxcms.com)!