Search code examples
gitgit-status

Why does Git ignore these folders?


I added a Laravel App under Git so that I could push to Bitbucket. On root folder, I ran git add -A and pushed on remote server. I checked that it did not send all folders; for instance, it did not add vendor folder at all. How do I make sure that all subfolders are added? When I run git status, it says:

# On branch master
nothing to commit, working directory clean

Update

I ran git status --ignore and found the following files listed:

stocktrack/app/storage/logs/laravel.log
stocktrack/app/storage/meta/services.json
stocktrack/app/storage/sessions/cdf664ccf42d040bc92d76418f736cc78e20d77a
stocktrack/app/storage/views/81774cd762e1fa0174ad42e0b0d53196
stocktrack/bootstrap/compiled.php
stocktrack/composer.lock
stocktrack/vendor/

In .gitignore, I only added .idea. Why did it ignore the others?


Solution

  • You can use git check-ignore to determine if a path is getting ignored by git.

    Furthermore check-ignore offers a -v (--verbose) option which will tell you about the pattern that ignores your file and where you can find it.


    Let's assume you have a repository with the following directory structure.

    bar/test/important
    foo/a.tmp
    foo/b
    

    And this .gitignore file.

    bar/
    foo/*.tmp
    

    You wonder why your important file in bar/test/ is getting ignored.

    This is a pretty bland example, but it just serves to show the concept.

    Now let's check which pattern ignores your important file.

    $ git check-ignore --verbose bar/test/important
    .gitignore:1:bar/       bar/test/important
    

    As you can see, check-ignore tells you that the pattern bar/ in your .gitignore file on line 1 ignores the path in question.