git add adding ignored files

后端 未结 10 2248
不知归路
不知归路 2021-02-01 00:58

I\'m trying to remove a previously tracked directory from git, which works, but it\'s being added back with each subsequent git add ., git add -A, etc.

10条回答
  •  灰色年华
    2021-02-01 01:38

    I created a repository to try and duplicate your issue, and I got the first answer from http://www.stackoverflow.com/questions/11451535/gitignore-not-working to work.

    Here's my repo if you are curious: https://github.com/IAMZERG/so_project_gitignore

    Try adding this to the .gitignore instead:

    **/directory_to_remove

    After that, run git rm --cached directory_to_remove -r

    git status should show that you deleted a bunch of files in the directory you are trying to remove. Then, commit and push to your remote, and everything should be golden... Maybe?

提交回复
热议问题