Fork me on GitHub

git删除误传的.idea文件

问题:

提交项目的时候忘记添加.gitignore文件,误上传了文件(如.idea)如何解决?如何删除Gitee地址上项目的.idea文件?(本文以.idea文件夹举例)

拉取项目

  • 拉取项目
    git pull origin master
  • 添加需要过滤的文件
a. 如果你有.gitignore文件,但是没添加误上传的文件夹(如.idea)
新起一行添加  .idea/
b. 如果你没有.gitignore文件,在你的项目里创建一个.gitignore的文件
将下面的文本放入即可

通用.gitignore文件

# Initially taken from Github's Python gitignore file

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
__pycache__
# C extensions
*.so
.DS_Store
.idea/
# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
#  Usually these files are written by a python script from a template
#  before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
.hypothesis/
.pytest_cache/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
.python-version

# celery beat schedule file
celerybeat-schedule

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/

data/
model/
  • 打开项目终端执行命令
# 删除github上的误上传文件.idea 
git rm -rf --cached .idea 
  • 提交.gitignore文件
git add .gitignore
  • 上传
git commit -m '忽略idea'
git push -u origin master

转载

https://www.cnblogs.com/trotl/p/11874108.html

posted @ 2020-07-19 16:32  晨度  阅读(488)  评论(0编辑  收藏  举报