开发者

GIT : How do I ignore a directory that is already in the repository without deleting or moving it?

开发者 https://www.devze.com 2023-03-29 12:29 出处:网络
Initially I wanted a directory and its contents to be managed in my project. Now I\'d prefer it was ignored entirely.I also want to continue working in it, so I don\'t want to move it or delete it.How

Initially I wanted a directory and its contents to be managed in my project. Now I'd prefer it was ignored entirely. I also want to continue working in it, so I don't want to move it or delete it. How do I accomplish this?

edit:

I forgot to mention that I do have a .gitignore file and that I did try to add it, but that doesn't seem to stop git from noticing modifications to files that were present in previous commits.

Maybe I'm not using the right pattern. Assuming t开发者_运维知识库he directory is called test, in the root, I've tried the following: test/ test/* test*


I'm pretty sure you need to remove the folder from the index.

git rm -r --cached test/

Then, add to .gitignore the test directory with just test/* assuming it is in the root.

Commit git ignore

git add .gitignore

git commit -m "added test directory"

Check to see if it worked with git status

And that should be it :)


Create a .gitignore file in the top level of your working directory. Add a line with the name of the directory you want ignored. Don't forget to add and commit your .gitignore!

See here for more info: http://book.git-scm.com/4_ignoring_files.html

0

精彩评论

暂无评论...
验证码 换一张
取 消