Unable to commit in Git

12.4k views Asked by At

When I enter in console:

$   git add .

I get:

Nothing added Nothing Specified. May be you wanted to say 'git add.'?

5

There are 5 answers

2
Shankar Narayana Damodaran On

Use the git commit

$ git commit -m "Yeah am saving it!."
4
Deepak Biswal On

Try this: $ git commit -am "Your commit message"

2
dax On

The order should look like this:

1) start a branch: git checkout -b my_cool_branch
2) do stuff on that branch
3) add the things you've changed to your commit queue: git add .
4) commit the things you added to your queue: git commit -m "i'm adding stuff!"

(optionally)
5) switch back to master (or whatever your main branch is): git checkout master
6) push your local commits to your github: git push origin master

The error you're seeing makes me think that you've skipped step 2 - are you sure you've made changes? run git status to see tracked/untracked changes.

0
AD7six On

There is nothing to commit

if git add . doesn't do anything there are two possibilities:

  • the directory you are in is empty
  • Everything in the folder is already tracked and hasn't changed OR is ignored

e.g. with an empty folder:

$ git add .
$ git status
# On branch master
#
# Initial commit
#
$ ls -la
drwxrwxr-x  3 andy andy 4096 Aug 26 11:34 .
drwxrwxrwt 11 andy andy 4096 Aug 26 11:34 ..
drwxrwxr-x  7 andy andy 4096 Aug 26 11:34 .git

Or, if everything is already tracked and unchanged:

$ touch foo
$ git add foo
$ git commit -m "adding foo"
[master (root-commit) d27092b] adding foo
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 foo
$ git add .
$ git status
# On branch master
nothing to commit, working directory clean
$ ls -la
drwxrwxr-x  3 andy andy 4096 Aug 26 11:34 .
drwxrwxrwt 11 andy andy 4096 Aug 26 11:34 ..
-rw-rw-r--  1 andy andy    0 Aug 26 11:35 foo
drwxrwxr-x  7 andy andy 4096 Aug 26 11:34 .git

Note that git status did not report any changes.

Ignored?

If a file/folder is ignored git will, well, ignore it :)

However you can still add it explicitly:

$ echo "bar" > .gitignore
$ touch bar
$ git add bar
The following paths are ignored by one of your .gitignore files:
bar
Use -f if you really want to add them.
fatal: no files added
$ git add -f bar
$ git status
# On branch master
# Changes to be committed:
#   (use "git reset HEAD <file>..." to unstage)
#
#   new file:   bar
#
# Untracked files:
#   (use "git add <file>..." to include in what will be committed)
#
#   .gitignore
$
0
jasir On

Try git add -A. This should add all to staging area (new files etc.)

From manual:

Like -u, but match against files in the working tree in addition to the index. That means that it will find new files as well as staging modified content and removing files that are no longer in the working tree.