Leem.fin Leem.fin - 1 year ago 52
Git Question

A proper way to ignore my file from version control in my case

My project is already in github. Now, I want to ignore a file which is already version controlled.

What I did was I added that file to

. I understand that for the already tracked file, only add it to
is not enough, so I also did:

git rm my_file


My goal is I would like
being ignored from version control, but still on hard disk so that my project can still run locally. But after I did
git rm my_file
, I am not able to run my project because the
is missing. I also run command
, and the file is not there.

How can I ignore the
from version control but still have it in my local disk so that my project can still run locally?

Answer Source

After listing your file in .gitignore you can just commit and push. this should delete the file on github. Try with:

git add --all
git commit -m "myFile gitignored"
git push

Notice that git add --all will add all your changed to the next commit!

I hope it helps.