We still haven’t created a commit; we’ve simply staged the file .gitignore to go in the
next commit. If we run
git status
again, we will see:
$ git status
On branch master
Initial commit
Changes to be committed:
(use "git rm --cached <file>..." to unstage)
new file: .gitignore
Now .gitignore is to be committed. We still haven’t created a commit yet, but when we
do, our changes to .gitignore will be in it. We could add more files, but let’s go ahead
and create a commit now:
$ git commit -m "Initial commit: added .gitignore."
The string that follows
-m
is the commit message: a brief description of the work
you’ve done in this commit. This allows you to look back at your commits and see the
history of your project unfold.
You can think of a commit as a snapshot of your project at a moment in time. We’ve
now taken a snapshot of the project (with only the .gitignore file in it), and you could
go back to that at any time. If you run
git status
now, Git will tell you:
On branch master
nothing to commit, working directory clean
Let’s make some additional changes to our project. In our .gitignore file, we’re ignor‐
ing any files named npm-debug.log, but let’s say we want to ignore any files with
the .log extension (which is standard practice). Edit the .gitignore file and change that
line to
*.log
. Let’s also add a file called README.md, which is a standard file that
explains the project in the popular Markdown format:
= Learning JavaScript, 3rd Edition
== Chapter 2: JavaScript Development Tools
In this chapter we're learning about Git and other
development tools.
Now type
git status
:
$ git status
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: .gitignore
20 | Chapter 2: JavaScript Development Tools