Git add . not working-> still “nothing to commit” with new files

638    Asked by LukeTurner in Devops , Asked on Jun 1, 2021

I am struggling with Git, I can't seem to add my files. I ran ls to show that the files are in the current directory, then run git add . then git status which showed "nothing to commit".

JJ-Computer:first_app JJ$ git init
Reinitialized existing Git repository in /Users/JJ/rails_projects/first_app/.git/
JJ-Computer:first_app JJ$ ls
Diary.txt README.rdoc log   tmp
Gemfile   Rakefile  db    public    vendor
Gemfile.lock  app   doc   script
README    config    lib   test
JJ-Computer:first_app JJ$ git add .
JJ-Computer:first_app Jenn$ git status
# On branch master
nothing to commit (working directory clean)
JJ-Computer:first_app JJ$

I think you are using the correct command (I've done them many times that way).

First, try

    git add --all

and then I tried git status. I don't think that will solve it, but it is worth trying next.

Another try looking at your .gitignore file, if you have one (in the top-level where you did git init).

    cat .gitignore

Remove any listings there that are causing your files to be ignored. For example, is there an entry with just *?

Next try:

    git add --force

and then apply git status.

In case, none of those work, I noticed that your output from git init says "reinitialized" rather than "initialized", so something may have gotten wrong. If you've just initialized it and if it's Okay for you losing history then I would consider you to start over by removing the .git dir:

    rm -rf .git

And then re-execute your same commands above. If that doesn't work, some more information about your setup will be required. For example, you might have a global .gitignore file: ~/.gitignore_global that needs to be edited (or removed if you don't want it).

Your Answer


Parent Categories