Joe Black
Joe Black

Reputation: 99

Git - adding ignore files to the .gitignore does not work

when I do a git push -f

My ignore files are also pushed to the online repository at https://github.com/

Is this a bug or I am doing something wrong?

I have added the file extensions to the .gitignore file like so;

.Web.config

Any pointers much appreciated.

Upvotes: 0

Views: 188

Answers (3)

Joe Black
Joe Black

Reputation: 99

Looks like if a file has been imported into git before it’s added to .gitignore you’re too late.

You have to remove the files from git using git rm and then commit and from then on, they will be ignored.

Upvotes: 0

Marco Vargas
Marco Vargas

Reputation: 1337

Not sure if I got your question, but as far as I got, you have something like this:

.
├── .gitignore
└── something.Web.config

And you want to ignore something.Web.config by adding it in the .gitignore

and you tried it by adding just .Web.config in the content of .gitignore

Well, if I got it right 👆

Just add the * at the beginning, something like:

*.Web.config

if you add it without the *, git will exclude files which full name is .Web.config but it seems it's not your case.

Also, make sure .gitignore is located in the right place, and not in a subfolder, but in the root of the project

Upvotes: 1

Fulgur
Fulgur

Reputation: 43

I use * as well, like so:

*.pdf

*.png

... and usually you don't need the -f flag for git push.

Upvotes: 1

Related Questions