I check out a project with git clone, added some files, and edited the README.md that had been check out.
When I do a git commit, I get this advice to add the file that I’ve checked out.
# 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: README.md
- Why is this file not staged?
- What can I do to so that this file will be automatically staged?
Git doesn’t add the changed files and new files to the commit. First you need to change the files to the index stage (changes to be commited). You can do this with
git add filefor new and modified files orgit rmfor removed files. Only the files that are listed in “changes to be commited” when you usegit statuswill be commited when you perform agit commit.One simple way to add changed files automatically when you perform a
git commitis to pass the option-a:git commit -a. This way, all changed files will be commited. However, new files and removed files will be not commited. If you want to commit only some changed files, you need to add each one manually withgit add.