4

I have got following problem:

I installed some dependencies (symfony) into my project using composer install.

BUT when I'm trying to commit that, It can't see any files.

I've searched every .gitignore file, but I think this is not caused by ignoring these files - I've checked it with SourceTree and these files are not even in "ignored" or "all", they simply don't exist in git at all.

So, I've tried git add vendor/symfony/*, git add vendor/symfony/*/* etc., but it just added some folders into commit, and not files.

When I move entire symfony folder, nothing changes. Same if I rename something. But, if I make some file in symfony folder, which contains just other folder (no files), it appears. But - if I make file next to another files in symfony, it won't appear.

I've looked into /.git/info/exclude, but there is also nothing suspicious.

Platform: Windows 7 x64 git 1.8.4

Is there something about composer I don't know? Or am I missing something?

Thanks for answers.

EDIT:

Well, it is kinda strange, but I made it work.

First I tried to add single file with its full path (with git add). CMD throwed error, it is unable to add, because this file is in submodule.

According this advice I've tried git rm --cached -r vendor/symfony, and it probably cleared some references.

Then I could call git add again, BUT I had to use path to files (there was many embed folders) like git add vendor\symfony\browser-kit\Symfony\Component\BrowserKit\*.

I actually don't know what happened, but after I made .bat file and call this on all files there, I can commit it.

Thanks for your time, help and advices. :)

Community
  • 1
  • 1
JaK
  • 133
  • 1
  • 7

2 Answers2

1

I am still new to git but I can share my own personal experience with adding files. I am still using various programs until I find a way that works best for me. I have installed MySysGit, TortoiseGit, and since I use GitHub I have the GFW program which installs PowerShell along with it.

Power Shell

The first thing I would type is git status. If you have untracked files then try to add the folder without the *. I have seen it recursively add files in the folder I specify and its sub directories. If that doesn't work then use TortoiseGIt.

git add vendor/symfony

As long as there is a vendor/symfony where you are in the shell it should add the files and it's sub directories.

TortoiseGIt

Right click the folder and look for a blue cross that says add. Once it discovers all the files select all and let it process them. Then use git status again to see what changed and possibly what else you need to do.

As long as there are untracked files TortoiseGit should add them and any sub directories.

Git Status

If git status doesn't show any untracked files, and there is no vendor/symfony in the git repo on your hard drive then I'd check and see if composer install needs other arguments to place the files where you expect them to go.

Sharlikran
  • 58
  • 8
  • 1
    Thanks, but it didn't help. Power Shell had no effect and Git Status says there is no untracked files. The thing is, that files really are there, I can see them via explorer. And they are on the right place :( – JaK Jul 17 '14 at 10:25
  • I wish my advice would have been helpful. I wasn't trying to just respond for no reason. I did look at [this link](http://adamcod.es/2013/03/07/composer-install-vs-composer-update.html) first. It's also why I suggested installing TortoiseGIt. If neither `git status` nor `TortoiseGit` see the files but you can manually copy files that Git will see, then there may be more to running composer install. I feel there are other arguments or steps for using composer that are being overlooked. Thus it has everything to do with composer and nothing to do with Git. Eliminating one thing anyway. – Sharlikran Jul 17 '14 at 11:26
  • Yes, I guess you are right. Meanwhile I solved it with Shell (see in edit of question), but your solution is more useful. Thanks for the tip on TortoiseGit and for your advice, it bringed solution to my head :) Thanks a lot! – JaK Jul 17 '14 at 11:42
  • Since you were able to add the files but have your doubts about the method to which you were able to add them, did you do the last step in that post? `$ find . -name .git` because having more then one `.git` folder, unless it's intended, is not a good idea. I would delete any unneeded `.git` folders unless you need that for composer to install and update other PHP packages. Check their documentation to be sure. – Sharlikran Jul 17 '14 at 11:58
  • Good point. Checked and it's okay. There was only one .git. Thanks :) – JaK Jul 17 '14 at 12:05
1

You are expected to add the whole vendor folder into .gitignore and not commit these dependencies into your own repository.

You can commit them, but if you happen to clone Git repositories, these will always be added as submodules, and I have been told they are not the best idea for Git. I would expect you to experience issues when trying to update.

I have very good experience with not committing these files, but to add a post-checkout hook into my local Git repo executing composer install. I only commit the composer.lock file. That way the repository stays small, but every checkout automatically updates all the dependencies.

Additionally, I have Phing scripts running tests, and as one step before that, composer install is also called.

Sven
  • 69,403
  • 10
  • 107
  • 109