How do I push files specified in .gitignore?

Alexander Trauzzi picture Alexander Trauzzi · Aug 3, 2012 · Viewed 12.9k times · Source

If I have a "vendors" directory in my .gitignore, is there a way I can set up a remote that will receive that directory anyway when I do a push?

Answer

larsks picture larsks · Aug 3, 2012

Your .gitignore file has nothing to do with pushing. It is used by things like git status and git add to figure out what files should be (or could be) part of a future commit. You can add things that are ignored using the git add command; it will throw an error unless you use the -f option:

The following paths are ignored by one of your .gitignore files:
somefilename
Use -f if you really want to add them.
fatal: no files added

Once you've added the file to the repository, it will be pushed along with any other changes.