Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git - how to unignore a file [duplicate]

Tags:

git

gitignore

Long story short, I accidentally added a file to .gitignore, which I committed and pushed.

Now I removed the file from .gitignore, but it's still not visible.

What else do I need to do?

like image 253
Lord Zsolt Avatar asked Dec 12 '13 16:12

Lord Zsolt


People also ask

How do I unignore a file in Git?

under the git repository. You can use patterns with ! as the prefix to “unignore” files. From gitignore man page: An optional prefix “!” which negates the pattern; any matching file excluded by a previous pattern will become included again.

How can I ignore files that have already been committed to the repo?

If you want to ignore a file that you've committed in the past, you'll need to delete the file from your repository and then add a . gitignore rule for it. Using the --cached option with git rm means that the file will be deleted from your repository, but will remain in your working directory as an ignored file.

Why Git ignore is not ignoring files?

gitignore only ignores files that are not part of the repository yet. If you already git add ed some files, their changes will still be tracked. To remove those files from your repository (but not from your file system) use git rm --cached on them.


1 Answers

I'm stupid, it was left in global gitignore, which is why it wasn't showing.

like image 179
Lord Zsolt Avatar answered Sep 22 '22 13:09

Lord Zsolt