Is there a way to not add vendor folder do git repository?

No one ever suggests to add vendor folder but git won’t allow the addition of any files without it.


Sorry, I have read the question wrong…

So I deleted my wrong response.


You should do that by Composer instead of manually. (To be honest I am not sure if I got the question correctly…)

Could you please explain exactly what your question is?

What are you trying to do?

What result do you want?

Every thing I read says do not include vendor folder in git repository. That is my goal. I created a new project with composer on the live server. Then I initialized git and attempted to add files i.e. $git add *

Git gave me a message to the effect of " .gitignore is excluding /vendor, us add -f if you really want to add them. No files added", and then it just stopped there. My question is how to get past this message, have git ignore the vendor folder like the .gitignore says and just add everything else.

My desired result is to have git ignore the vendor folder and not abort the initial adding of files unless I do git add -f *, and force me to include the vendor folder.

I add /vendor to my .gitignore, and that works.

Check that there isn’t a .git folder at the root at your project - remove it if it is - and do a git init and then add.

If that fails too, consider using a GUI.

I use a GUI whenever I can. Smartgit is my favorite. I don’t trust myself, especially when performing the initial adding/staging/committing voodoo. :)

I started with a fresh clean install of yii2 via composer, no .git folder yet. Then I did git init. Next step was git add *. That is when I got the message(paraphrasing), “One of your .gitignore files says to ignore /vendor directory, use git add -f if you really want to include them. Aborted, no files added.” That’s where I am, either I include vendor directory or no files get added.

Create a .gitignore at the root of your project, then add this to it:


Then try again. What says git?

Try "git add -A" instead of "git add *".

That’s one of the main reasons why I prefer Mercurial ;)

The git command-line is really mysterious, and unforgiving.

I don’t like the git command-line, either. ;) I’m using tortoise git. :)

SmartGit for me - especially when I have to add files - I really prefer a visual representation of what’s going on.

I get real grumpy when someone asks a question, and then leaves the building, never to return!

Did it work? Or not?