GitHub: Commit

Using Git to Track/Record Changes

In my last article I demonstrated how to use the Git bash command-line to setup a new repo. In this article, I’ll show how to use commit to track and record changes.

I’m starting with an empty repo so first I’ll add a new blank

Now, I’ll see if Git noticed the addition.

Notice the message indicated a new file, but it’s “untracked,” and needs to be staged for the next commit, which is how changes are added to the git Db.
Therefore, I’ll add the file and recheck git status.

So far, I’ve performed an add, then commit, but git allows multiple files to be added simultaneously, saving time.

First, I’ll create a few test files to demonstrate this feature.

Now, I’ll use the dot (‘.’) operator with add to add multiple files to staging with one command.

With all new files added, I’ll perform my first commit.

Similar to how I added multiple file simultaneously, I can also commit multiple changes, but without staging.

First, I’ll open and modify each text file, then recheck the git status.

As you can see, git recognizes the changes, but states they are “not staged for commit.”

I could use the add command again, but to save time, I’ll use the -a option with commit the changes without staging them first.

Finally, I’ll list all commits performed so far.