This will create a project repository for you (there’s now a hidden directory called .git
in your project root).
Inevitably, there will be some files you never want tracked in version control: build
artifacts, temporary files, and the like. These files can be explicitly excluded in a file
called .gitignore. Go ahead and create a .gitignore file now with the following contents:
# npm debugging logs
npm-debug.log*
# project dependencies
node_modules
# OSX folder attributes
.DS_Store
# temporary files
*.tmp
*~
If there are any other “junk” files that you know of, you’re welcome to add them here
(for example, if you know your editor creates .bak files, you would add *.bak to this
list).
A command you’ll be running a lot is
git status
, which tells you the current status
of your repository. Go ahead and run it now. You should see:
$ git status
On branch master
Initial commit
Untracked files:
(use "git add <file>..." to include in what will be committed)
.gitignore
nothing added to commit but untracked files present (use "git add" to track)
The important thing that Git is telling you is that there’s a new file in the directory
(.gitignore), but it’s untracked, meaning Git doesn’t recognize it.
The basic unit of work in a Git repository is the commit. Currently, your repository
doesn’t have any commits (you’ve just initialized it and created a file, but you haven’t
registered any of that work with Git). Git doesn’t make any assumptions about what
files you want to track, so you have to explicitly add .gitignore to the repository:
$ git add .gitignore
ES6 Features | 19