I want to gitignore a folder which has already been committed to upstream and distributed among all forks. I need those files to be removed only from git versioning not to delete for my file system and to not delete from any forks local file system. Is there anyway for this?
I attempted the following steps:
- Added the path to folder in my
.gitignorefile likemy_ignore_folder/*. - Then run command
git rm -r --cached my_ignore_folder/* - then
git add --all - then
git commit -am "ignored folder" - then
git push origin my_branch name
After doing the all these things I did ls my_ignore_folder/ and found all the files exists in my file system as it is as expected. Then I switched to a different branch by git checkout another_branch where these files are still not ignored. So ls my_ignore_folder/ displays all files. Then again when I switched back to my earlier branch where those files were just ignored and run ls my_ignore_folder/ then I surprisingly found my_ignore_folder/ is missing. I attempted it number of times but same thing is happening. Can anyone please explain why this happening. Am I doing anything wrong? I expected my ignored files to not get deleted from my local file system. Is there any way by which it can be achieved? Please help.