git-add
Stage changes for commit
TLDR
Add a file to the index
Add all files (tracked and untracked)
Add all files recursively starting from the current folder
Only add already tracked files
Also add ignored files
Interactively stage parts of files
Interactively stage parts of a given file
Interactively stage a file
SYNOPSIS
git add [
PARAMETERS
-n, --dry-run
Don't actually add the file(s), just show if they exist and/or will be ignored.
-v, --verbose
Be verbose.
-f, --force
Allow adding otherwise ignored files.
-i, --interactive
Add modified contents interactively.
-p, --patch
Add modified contents interactively.
-e, --edit
Open the diff in an editor and let the user edit it before adding it.
-u, --update
Update the index only where it already has an entry matching
--all, --no-ignore-removal
Update the index not only where the working tree has a file matching
--intent-to-add
Record only the fact that the path will be added later. An entry for the path is placed in the index, but the file contents are not copied. This is useful for, among other things, showing the intent to add a file which you know will appear later, but do not need to include in this commit.
--refresh
Don't add the file(s), but only refresh their stat information in the index.
--ignore-errors
If some files could not be added because of errors, do not abort the operation, but continue adding the others. The command shall still exit with a non-zero status.
--ignore-missing
This option can only be used together with --dry-run. By using this option the command will not error out if
--chmod=(+|-)x
Override the executable bit of the added files.
--pathspec-from-file
Pathspec is passed in
--pathspec-file-nul
Only meaningful when --pathspec-from-file is used. Pathspec elements are separated with a NUL character and all other characters are taken literally (including newlines and quotes).
DESCRIPTION
The git add command is used to stage changes for the next commit. It adds the specified files or directories to the staging area (also known as the index). This command doesn't commit the changes to the repository; it only prepares them to be committed. Before you can commit changes, you must use git add to tell Git which changes you want to include in the next commit.
You can specify individual files, directories, or use wildcards to add multiple files at once. The command also intelligently handles new files and modifications to existing files. When you add a directory, Git recursively adds all files and subdirectories within that directory. git add . is a common shortcut to stage all changes in the current directory and its subdirectories. The changes are not permanently saved until you run git commit.
CAVEATS
Changes are only staged, not committed. You still need to run git commit to save them permanently.
IGNORING FILES
Files listed in the .gitignore file are typically excluded from being added unless explicitly specified using the -f or --force option.
INTERACTIVE ADDING
The -i and -p options provide interactive ways to review and stage changes, allowing you to selectively add parts of files to the staging area.