git add

Staging all changes

The most common way to stage everything in the working tree — new files, modifications, and deletions.

$ git add .

Note: . stages changes relative to the current directory. From the repo root this covers all tracked and untracked files.

Including untracked and deleted files explicitly

The -A flag stages all changes across the entire repository regardless of where you run the command.

$ git add -A

Staging a specific file

Provide a path to stage only that file, leaving other changes unstaged.

$ git add <file>

Multiple files can be listed in a single command:

$ git add src/app.js src/utils.js

Staging files by pattern

Shell glob patterns let you stage groups of related files without listing each one.

$ git add *.js
$ git add src/**/*.ts

If certain files should never be staged, add them to a .gitignore file. See ignoring files for details.

Staging changes interactively (hunks)

The -p (patch) flag opens an interactive prompt that walks through each changed hunk, letting you choose exactly which changes to include in the next commit.

$ git add -p
$ git add -p <file>

At each hunk you can type: - y — stage this hunk - n — skip this hunk - s — split into smaller hunks - e — edit the hunk manually - q — quit and stop staging

Checking what is staged

After staging, use git status to see which files are staged and which are not. To review the exact line-by-line changes that will be included in the next commit, run git diff --staged:

$ git diff --staged

Once your code is ready, DeployHQ can deploy it to your servers automatically from any Git repository.