简体   繁体   中英

Files are not being tracked after creating a git repo for my laravel project

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?

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 ).

give the entire path/url of the git repository where the project is to be stored in the following command - git remote add origin NAME_OF_REPO ie git remote add origin http://github.com/accoutname/repositoryname.git

which you can copy the URL available on top rightside of your GitHub repository

and then write the following command - git push origin master

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM