git mistakenly deleted files uploaded .idea

Question:
When submitting projects .gitignore forget to add files, mistakenly uploaded files (such as .idea) how to solve? (Herein, for example to .idea file folder)

1. Pull down the project file

git pull origin master

2. Add file to be filtered

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

General .gitignore file

# 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/

3. Open a terminal program execution command

# 删除github上的误上传文件.idea 
git rm -rf --cached .idea    

4. Submit .gitignore file

git add .gitignore

5. Upload

git commit -m '忽略idea'
git push -u origin master

Guess you like

Origin www.cnblogs.com/trotl/p/11874108.html