Terminology
- Project
- A directory that contains all the files needed for a website or application to function.
Prerequisites
- Git installed
- Existing project that’s not a repo (i.e. a directory of text files)
Initializing a new repo
- Using the terminal, navigate to your project directory.
-
Confirm that you are not already in a git repository:
$ git status
should return “fatal: not a git repository” or similar. If the command outputs branch information, you’re inside a repo you’ve already created. That’s a tricky situation you should ask your closest Git nerd about.
-
Initialize an empty repo. Note: It’s very important that you are in the root folder of your project when you do this.
$ git init
-
Stage your project files. “Staging” is an extra step you need to do before you can commit any changes. This gives you better control over your commit history (although it can be a pain).
$ git add --all
-
Commit your changes. This is Git’s version of saving your files.
$ git commit -m "initial commit"
-
Confirm that you’re up to date.
$ git status
You can never
git status
too much. If you have no changes to stage or commit, you’ll see a message similar tonothing to commit, working tree clean
.