git status --Check if commit is ready

Use the "git status" command to see if it's ready to commit.

#Check if commit is ready
git status

What is commit preparation?

In Git, instead of committing suddenly, the task of preparing for commit is done before committing. Think of it as the task of deciding which files to commit. You can commit using git commit, but before that, prepare for the commit. Officially called indexing, or staging, we'll use the term commit preparation here for the sake of clarity.

If not ready to commit

Here is an example of the output of the "git status" command when it is not ready for commit.

#On branch master
#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: templates / blog / 20201109142343.html
#Untracked files:
# (use "git add <file> ..." to include in what will be committed)
# a.txt
# templates / blog / 20201110105057.html
no changes added to commit (use "git add" and / or "git commit -a")

The newly created file is shown as not yet tracked.

The modified file will show that it has not yet been prepared (staging) for commit.

When ready to commit

Use the " git add" command to prepare for commit. Let's take a look at the state after executing "git add".

#Preparing to commit
git add.

#Check if you are ready to commit
git status

Let's see the output result of "git status".

#On branch master
#Changes to be committed:
# (use "git reset HEAD <file> ..." to unstage)
# new file: a.txt
#modified: templates / blog / 20201109142343.html
# new file: templates / blog / 20201110105057.html

You will see that your changes are ready to be committed.

After confirming the file to commit, use the "git commit" command to commit.

Associated Information