I am working on a Laravel project which contains around 37000 files. When I add this project to SourceTree (Git GUI) I am using. It shows me all 37000 files as new/unstaged. But I only want to add the files I programmed myself (e.g. routes file, few models files, controllers etc..) and not all the framework files that are around 37000. How to avoid adding all the framework files to the git/github by using GUI. Or what is the proper way of doing such task where we have a large project (thousands of files) and we only want to use few files with git from it? Or if it is possible to ignore some directories like verder, storage, nor_module etc..
2 Answers
Add all the unwanted files and directory into .gitignore
.

- 8,922
- 6
- 28
- 48
-
But how can all 37000 files be added to .gitignore with a complex directory structure? It would take months – Murtaza Jul 21 '16 at 04:00
-
@Murtaza: If you would like to ignore all the file of type `.log` then adding `*.log` into `.gitignore` will do the trick. – Shravan40 Jul 21 '16 at 04:03
-
yes, but if I ignore (e.g all PHP files) that also include the files I want to use. – Murtaza Jul 21 '16 at 04:04
-
You can exclude certain file too. Please read `git pro` once. It will resolve all your doubts. – Shravan40 Jul 21 '16 at 04:06
-
I think he is asking how to exclude committing the Laravel framework files. See my answer below about utilizing Composer for dependency management. You should not be committing your _vendor_ directory in version control. – Sameer A. Jul 21 '16 at 04:08
Utilize a .gitignore file. Make sure to not commit the vendor directory, as this will include all of the composer dependencies. You should commit a composer.json file that contains all of your dependencies. When you pull down your code from GitHub, you can simply run composer install to download the dependencies.
Note that the Laravel framework is a dependency, so this will be in your composer file.
Take a look at Composer. If you're using the Laravel framework, or really any PHP framework, it's important to understand how Composer works. It can save a lot of hassles with dependency management.
Your .gitignore should look like:
/vendor
/node_modules
/public/storage
This will exclude the framework files and other (PHP and JS) dependencies your project may require.

- 167
- 1
- 2
- 15
-
yes, problem solved ;) Very clear instructions you provided. Ignored some heavy dependency directories and left with only working files that I wanted to use :) Thansk – Murtaza Jul 21 '16 at 04:22
-
I'm trying to add Mapbox framework, Could you please help me and check the attached question. https://stackoverflow.com/questions/70751846/sourcetree-github-when-pushing-return-error – Sham Dhiman Jan 31 '22 at 16:37