Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
865 views
in Technique[技术] by (71.8m points)

git - gitignore does not ignore folder

In the root of my project I have a foo folder. Inside the foo folder I have a bar folder. I would like to ignore all changes to all files inside my bar folder. I have this in my gitignore:

/foo/bar

The folder is checked: it exists and it has the files to be ignored. gitignore is committed. However, I have a file where I make a moification and is inside my bar folder. When I type

git status

inside my git bash I see the file which should have been ignored. What could be the reason and how can I successfully ignore all files inside my bar folder?

Note, that the files were previously ignored with the same line, but I had to temporarily remove that line to commit something on the server. After the commit, I put back the line into the gitignore. This was a while ago, but now I have observed that the files will be in git status. I would expect to be able to modify the ignored files without they appearing in the git status.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I'm guessing this folder has been checked into git before?

Run git rm -r --cached <folder> and check again.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...