Git: Add Files

By Xah Lee. Date: . Last updated: .

What is Git Add

After you made change to files, you need to do the following steps, in order:

  1. Add the file to staging area.
  2. Commit staging area (files) into (local) repository. 〔see Git: Commit Files
  3. Optionally, git push to a remote repository. 〔see Git: Push to Server

Any file you want to commit, you must first git add, even if the file already exists in the repository.

The git add command basically means add it to the “index” file. The purpose of “index” is for next commit. This “index” file is also called “staging area”.

How to Add Files

  1. cd xProjectDir
  2. git add xfilename

git add commands:

git add file1 file2 file3
several files.
git add .
all files in current dir. (including new and deleted)
git add -u
all tracked files in current dir. (no new files)

git add, commit