Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

git add . -> still "nothing to commit" with new files

Tags:

git

add

init

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 ran 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 config.ru 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$  
like image 673
RandyMy Avatar asked Jun 02 '12 03:06

RandyMy


People also ask

Why my git add is not working?

This is because the node_modules folder is not ignored and hence when we run git add . command git visit all your directory/files and sub directory/files which is not ignored in . gitignore hence it is taking so long time to process it as node_modules contains a large amount of files and folder.

Why does git say nothing commit?

The Git “nothing to commit, working directory clean” message tells us that we have not made any changes to our repository since the last commit. If this message appears and the contents of your remote repository are different to your local repository, check to make sure you have correctly set up an upstream branch.

Does git commit add new files?

To add and commit files to a Git repositoryEnter git commit -m '<commit_message>' at the command line to commit new files/changes to the local repository. For the <commit_message>, you can enter anything that describes the changes you are committing.


2 Answers

Your commands look correct (I've done them many times that way).

First try

git add --all 

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

Next 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 try git status.

If none of those work, I notice that your output from git init says "reinitialized" rather than "initialized", so something may have gotten messed up. If you've just initialized it and don't mind losing history, start over by removing the .git dir:

rm -rf .git 

And then reexecute 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 edited (or removed if you don't want it).

like image 131
quux00 Avatar answered Sep 19 '22 11:09

quux00


Since I've experienced a similar issue multiple times I would just like to add that you should double check that you're trying to add from and are currently in the root folder of your project.

like image 27
jimjoebob123 Avatar answered Sep 20 '22 11:09

jimjoebob123