1

Helloo,

Recently i started my first Laravel project. I installed it using the following command:

composer create-project laravel/laravel laraveltest

Now after writing some code, I thought it would be a good idea to track my project using Github. I've created repositories from existing projects before, and thought it would be the same way, but something which i cannot understand is happening. These are the steps i tried to track the project using Github:

  1. I've created an empty Github repository without gitignore file or readme.

  2. Inside my project folder i ran these commands:

git init

git add .

git commit -m "initial commit"

git remote add origin NAME_OF_REPO

git push origin master

Now my problem is that when i do this Github only tracks these 2 files:

new file:   .gitignore
new file:   readme.md

and when i check what's being ignored using the git status --ignored command i can see everything is being ignored somehow:

Ignored files:
  (use "git add -f <file>..." to include in what will be committed)

    .env
    .env.example
    .gitattributes
    .idea/
    app/
    artisan
    bootstrap/
    composer.json
    composer.lock
    config/
    database/
    package.json
    phpunit.xml
    public/
    resources/
    routes/
    server.php
    storage/
    tests/
    vendor/
    webpack.mix.js

The thing is my .gitignore file looks like this:

cat .gitignore :
/node_modules
/public/hot
/public/storage
/storage/*.key
/vendor
/.idea
/.vagrant
Homestead.json
Homestead.yaml
npm-debug.log
yarn-error.log
/.env

So why are only my gitignorefile and readme file tracked? i tried googling it but couldn't find anything.

Thank you in advance.

UPDATE

It seems that the problem only exists on a specific computer. I copied the project to another computer and completed the same steps as mentioned above, and now it works. Git is tracking everything fine.

So i guess now my question would be: How do i troubleshoot this problem on the computer it's not working on? is it possible somehow Git reads the .gitignore-file from another repo on that computer?

Mathijs
  • 61
  • 1
  • 8
  • The idea is that GIT should only track files you create. You dont want the other files tracked as they are not yours. They get created by installing Laravel and possibly also running Composer to get extra packages. But as none of those are actually your code, GIT should not track them – RiggsFolly Aug 22 '18 at 11:50
  • So why aren't my created files tracked by git then? i'm not ignoringen them in my .gitignore? – Mathijs Aug 22 '18 at 11:56
  • Have you created any of your own file yet? I mean file for you rproject, or is this just a vanilla Laravel install – RiggsFolly Aug 22 '18 at 11:57
  • What I said was: GIT should NOT track Laravel or packages you add using composer. Thay are not yours. It SHOULD track only file that YOU create as part of your project – RiggsFolly Aug 22 '18 at 11:58
  • @RiggsFolly yes I already created my own files before creating the local repo and adding the files, so i expected them to be tracked by git – Mathijs Aug 22 '18 at 12:07
  • In your question, right below `git push origin master`, do you mean Git or Github? – Chukwuemeka Inya Aug 22 '18 at 12:55
  • @ChukwuemekaInya i mean git i guess – Mathijs Aug 22 '18 at 13:34
  • Git has several places where it looks for ignore files. Have you set `core.excludesfile` in global git config (cf. https://stackoverflow.com/a/7335487/3906760). – MrTux Aug 23 '18 at 12:50
  • @MrTux this is it, thank you! – Mathijs Aug 27 '18 at 08:20
  • @Mathijs I added my comment as an answer. – MrTux Aug 27 '18 at 08:27

2 Answers2

0

Git has several places where it looks for ignore configuration files.

  1. It looks for .gitignore files in every folder of the working tree
  2. Inside the working tree (should be empy in your case) it looks for .git/info/exclude
  3. You can configure a global or system wide exclude file: Have you set core.excludesfile in global git config (cf. https://stackoverflow.com/a/7335487/3906760).
MrTux
  • 32,350
  • 30
  • 109
  • 146
-1

I think everything seems fine. Just do a git add ., git commit -m "Commit message" and git push origin master. Make some changes and check again.

Chukwuemeka Inya
  • 2,575
  • 1
  • 17
  • 23
  • This is exactly what i did. – Mathijs Aug 23 '18 at 10:55
  • Do it again for your `.gitignore` and `readme.md`. Make more changes. You should be fine. – Chukwuemeka Inya Aug 23 '18 at 11:22
  • First of all, thank you for helping me. But my problem is that Git just ignores everything. When i run the commands in your answer, it only starts tracking the `readme`-file and the `.gitignore`-file. – Mathijs Aug 23 '18 at 12:19
  • Check this link out. https://stackoverflow.com/questions/11451535/gitignore-is-not-working . Scroll down to the accepted answer. Something to do with file encoding. Might help. – Chukwuemeka Inya Aug 23 '18 at 12:55