git add <path>

Stages changes in the specified <path> so they are included in the next commit.

This command is used to prepare changes in a specific path to be recorded in the next commit. It updates the staging area so that only the selected files or directories in <path> will be committed, letting you control exactly what goes into each commit.

The add subcommand tells Git to take changes from your working directory and copy them into the staging area. The <path> parameter can be a single file, multiple files, a directory, or a pattern (such as src/ or *.js), and only those matching paths will be staged.

Related: Use git add . to stage all changes in the current directory, git add -p to interactively choose hunks to stage, or git status to see which files are staged versus unstaged.

Examples:

  • git add src/index.js
  • git add src/components/
  • git add README.md LICENSE
Manual page
git add
Related commands

Welcome to GitExamples!

Sign in to gitexamples