Forrest logo
back to the git tool

git-add:tldr:3a6a8

git-add: Interactively stage a file.
$ git add -i
try on your machine

The command "git add -i" is used to launch Git's interactive mode for adding changes to the staging area. It allows you to selectively choose which changes you want to add, instead of adding all changes at once.

By running this command, Git will present you with a menu, providing options for different types of changes you can interactively add. These options typically include:

  1. Patch - This allows you to choose specific changes from the diff to add.
  2. Update - This updates the index with the most recent changes from the working directory.
  3. Revert - This removes previously added changes from the index.
  4. Add untracked - This adds untracked files to the index.
  5. Patch untracked - This allows you to selectively choose specific changes from untracked files to add.

Once you select an option, Git will guide you through the process of interactively adding changes to the staging area.

Interactive mode is useful when you have multiple changes and want to carefully review and select which ones to add. It gives you more control and flexibility over the staging process, allowing you to split changes into separate commits or exclude certain modifications from being committed.

This explanation was created by an AI. In most cases those are correct. But please always be careful and never run a command you are not sure if it is safe.
back to the git tool