问题描述
我搜索了一下,发现了一些教程来解决问题,不幸的是他们没有奏效。
基本上发生了什么是我在.gitignore中有文件,我使用的mac程序的github正在尝试提交,尽管它们被忽略。我发现一些博客,甚至在stackoverflow上的其他帖子,说你可以用命令行修复它,并给出解释如何。不幸的是,我对命令行毫无经验,而且我试图遵循他们的指示都未能解决问题。
有没有办法解决这个问题而不使用命令行?如果没有人可以告诉我如何使用命令行破解发现其他地方:
git rm -r --cached。
git add。
git commit -mfixing .gitignore
这些文件是否已经被跟踪,并且GitHub for Mac正在尝试修改这些文件? .gitignore
只会阻止未跟踪的文件被git添加/提交。一旦跟踪了一个文件, .gitignore
停止咨询。
您链接的hack实际上只是要求git删除回购库中的所有文件,然后重新添加回去。这是可行的,因为在重新添加文件时会查询 .gitignore
(因为它是针对索引中尚未包含的任何文件进行咨询的,而 git rm -r --cached。
删除了整个索引)。
I searched around and found some tutorials explaining out to fix the problem, unfortunately they haven't worked.
Basically what's happening is I have files in the .gitignore that the github for mac program I'm using is trying to commit, despite them being ignored. I found some blogs and even other posts on stackoverflow saying that you can fix it with the command line, and giving explanations how. Unfortunately I have absolutely no experience with the command line and my attempts to follow their directions have all failed to solve the problem.
Is there a way to fix this problem without using the command line? and if not can someone tell me how to use the command line hack found here among other places:
git rm -r --cached .
git add .
git commit -m "fixing .gitignore"
Are these files already tracked, and GitHub for Mac is trying to commit the modifications? .gitignore
only prevents untracked files from being added/committed by git. Once a file has become tracked, .gitignore
stops being consulted.
The "hack" you linked is really just asking git to delete all of the files in the repo, then re-adding it all back. This works because the .gitignore
will be consulted when re-adding files (because it's consulted for any files not already in the index, and the git rm -r --cached .
deleted the entire index).
这篇关于.gitignore不能在github for mac程序中工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!