Git Commit
Now that you've created your `index.html` file, it's time to start tracking it with Git. To do this, you'll use the `git add` command to tell Git to keep an eye on the file, and then you'll use the `git commit` command to save a snapshot of your work.
Add Your File to the Repository
Before you can save your changes, you need to add the file to Git's "staging area." This is like telling Git, "Hey, I'm ready to save this file!"
Run the following command to add the index.html file to version control:
git add index.html
After running the command, you'll see something like this when you check the status with `git status`:
On branch master No commits yet Changes to be committed: (use "git rm --cached
..." to unstage) new file: index.html This means that `index.html` is now staged, or ready to be committed. It's like putting a stamp on a letter before mailing it.
Commit Your Changes
Now that your file is staged, you can save a snapshot of your work by committing the changes.
Run the following command to commit your changes:
git commit -m "First Commit"
The `-m "First Commit"` part is where you add a message describing what you've done. In this case, the message is "First Commit," but you can write anything that makes sense to you.
After committing, you'll see something like this:
[master (root-commit) 0746f1f] First Commit 1 file changed, 1 insertion(+) create mode 100644 index.html
This tells you that your `index.html` file has been successfully committed.
Check the Status Again
To make sure everything is in order, you can run the `git status` command again:
git status
You should see:
On branch master
nothing to commit, working tree clean
This means you've successfully committed your changes, and your project is up to date!