問題:
提交項目的時候忘記添加.gitignore文件,誤上傳了文件(如.idea)如何解決?(本文以.idea文件夾舉例)html
git pull origin master
python
a. 若是你有.gitignore文件,可是沒添加誤上傳的文件夾(如.idea) 新起一行添加 .idea/ b. 若是你沒有.gitignore文件,在你的項目裏建立一個.gitignore的文件 將下面的文本放入便可
通用.gitignore文件git
# 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
git add .gitignore
git commit -m '忽略idea' git push -u origin master