Git: Create Project

By Xah Lee. Date: . Last updated: .

To create a new project from scratch, do:

  1. cd projectDir → go into your project dir
  2. git init → initialize the dir to be a git repo.
  3. git add . → add all files in the dir to git.
  4. git commit -m"first commit" → commit to the (local) git database.

here's a sample with more explanation:

# cd to the dir containing your code
cd xx
# the directory can also be empty.

# initialize.
# This creates a .git dir in the current dir.
# This dir holds all git's data about the current project.
git init

# add all files of current dir (including subdir and files) to git staging area
git add .

# commit to local repository
git commit -m"my first commit"

The .git directory holds all git's internal data.