Staging and Committing
Now that we’ve made changes to the index.html file, we need to stage them before we can save them with a commit.
What Does Staging Mean?
Staging is like getting your changes ready to be saved. When you stage a file, you’re telling Git, "I’m ready to save this change in my next commit."
Stage the index.html File
To stage the change we made, we use the git add command. This command has many uses, but here we’re using it to stage the file. Let’s run the command:
git add index.html
Now, if you run the git status command again:
git status
You should see something like this:
On branch master
Changes to be committed:
(use "git restore --staged ..." to unstage)
modified: index.html
This means that the file index.html is now staged and ready to be saved in your next commit.
Commit the Changes
Now that the file is staged, it’s time to commit the changes. We use the git commit command for this. Let’s run it:
git commit -m "make university awesome"
You should see something like this:
[master 7f0f66a] make university awesome
1 file changed, 1 insertion(+), 1 deletion(-)
This means your changes have been saved (committed)!
Check the Status Again
Let’s check the status one more time by running:
git status
You should see:
On branch master
nothing to commit, working tree clean
This message tells us that everything is saved, and the working directory is clean - meaning there are no more changes to be committed!