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
707 views
in Technique[技术] by (71.8m points)

git to ignore a hidden directory in the local repo

I just initialised a project directory to be a git local repo by doing git init

But ls -la shows that there is a hidden directory ".idea" which I think I don't need to track with my project. If that is correct, I tried to add it to my .gitignore buy just appending a ".idea/*" at the end of that file.

git status still shows the .idea/ listed.

Reading other posts on SO did not help me much since they are trying to stop tracking files which are already being tracked, or on the remote repo.
I am trying to start a fresh and ignore .idea/ from the very beginning and on the local repo before pushing anything to the remote repo. Thanks

See Question&Answers more detail:os

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

1 Reply

0 votes
by (71.8m points)

You can use git rm to remove the file in .idea folder from being tracked. What I usually do for my projects with Intellij IDEA, is like this :

git rm -r --cached .idea/

then

git add .
git commit -m "Excluded .idea from being tracked"
git push 

From this moment on, the git won't track the idea folder any more.

You can also take a look at the answers for this question.


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

...