Saturday, 23 April 2016

What does "Changes not staged for committed" means in Git ?


When you run "git status" command , you may see the warning message “Changes not staged for commit” for some files like,

$ git status
On branch master
Changes to be committed:
  (use "git reset HEAD <file>..." to unstage)
    new file: Hello.txt

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)
    modified: newFile.dat

It means that a file that is tracked has been modified in the working directory but not yet staged.

 

Solution
To stage it, you run "git add" command.
"git add" is used to begin tracking new files, to stage files, and to do other things like marking merge-conflicted files as resolved.

It acts like “add this content to the next commit”

$ git add newFile.dat
$ git status
On branch master
Changes to be committed:
  (use "git reset HEAD <file>..." to unstage)
    new file:   hello.txt
    modified:  newFile.dat
 

No comments:

Post a Comment

Note: only a member of this blog may post a comment.