简体   繁体   English

.gitignore文件在git push期间不忽略某些文件?

[英].gitignore files not ignoring certain files during git push?

Contents of my .gitignore file within my project directory: 项目目录中我的.gitignore文件的内容:

bin/
.settings/
.classpath
.project
MyGuide.txt
.gitignore

What is showing up in my github project: 我的github项目中显示了什么:

在此处输入图片说明

Is there a reason "MyGuide.txt" and the .gitignore files are still being displayed when I push to my remote repo? 当我推送到我的远程仓库时,是否仍然会显示“ MyGuide.txt”和.gitignore文件?

Looks like your file is already added to the git repo. 看来您的文件已添加到git repo中。

Once file is added (not untracked) adding it to .gitignore will not ignore it since its already in the repo so you have to remove it from the repository, commit the deletion of the file and then it will be ignored. 一旦添加了文件(未取消跟踪),将其添加到.gitignore便不会忽略它,因为该文件已经在存储库中,因此您必须其从存储库中删除,提交文件的删除操作,然后它将被忽略。

# Remove any file you have already commited and you wish to ignore
git rm -rf --cached .idea/*

# now add the ignored pattern to your .gitignore file
git add -A .

# commit and push the removal of the ignored files.
git commit -m "Removed idea files"
git push

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM