albanx
albanx

Reputation: 6335

Git cannot push folder part of another git project

I just updated elephant.io in my project with composer, and I am trying to push it to remote, but when I do that git seems to see elephant.io directory as a file and it does not push it? is this a bug? I am using git 1.7.11 on bitbucket.

EDIT

Probably is not the dot the problem but something else. Doing :

git ls-files --stage | grep 160000

I get

160000 8e151a58e931c87ef1b7d2d2124f5b8d79637d1e 0   vendor/wisembly/elephant.io

**EDIT 2: Solution ** The final problem was that I was including the vendor folder in the git, and the error comes from the packagest that comes with their .git configuration. Ignoring vendor folder solves the problem. Thank you both to Sven and Vonc

Upvotes: 2

Views: 1046

Answers (2)

VonC
VonC

Reputation: 1323793

Since elephant.io is a submodule with a special entry 160000 8e151a58e931c87ef1b7d2d2124f5b8d79637d1e, you need to make sure that:

  • you have added, committed and push any modification done in elephant.io

      cd vendor/wisembly/elephant.io
      git add . 
      git commit -m "my modifs to elephant.io"
      git push
    
  • then you would go back to the parent repo, add and commit the new special entry SHA1:

     cd ..
     git add .
     git commit -m "new revision of elephant.io"
     git push
    

But that only works if you have the right to push back to elephant.io (or you shouldn't make any modification in it, or at least your submodule should reference a fork of elephant.io that you own).

In any case, to be clear, elephant.io being "not" pushed has nothing to do with the fact it has a dot in its name.

As suggested by Sven, since composer takes care of the dependencies, you could simply ignore the vendor folder. That will make those submodules invisible from the parent repo.

Upvotes: 3

Sven
Sven

Reputation: 70863

If you are using Composer, and there is no special requirement for you to include the dependencies in your own repository, I'd think it is a good idea to follow the suggestion of the Composer developers to NOT include the vendor folder in your own repository, but only add and commit the composer.lock file.

Add the line vendor/ to your .gitignore file in the topmost directory, and you are basically done.

More info: https://getcomposer.org/doc/faqs/should-i-commit-the-dependencies-in-my-vendor-directory.md

Upvotes: 2

Related Questions