Home Explore Blog CI



git

5th chunk of `Documentation/git-add.adoc`
a8ce68abc917af8c6328529afb3bd6863f2fe4cfc9e1978e0000000100000923
 HEAD version.  Reverting new paths makes them untracked.

add untracked::

  This has a very similar UI to 'update' and
  'revert', and lets you add untracked paths to the index.

patch::

  This lets you choose one path out of a 'status' like selection.
  After choosing the path, it presents the diff between the index
  and the working tree file and asks you if you want to stage
  the change of each hunk.  You can select one of the following
  options and type return:

       y - stage this hunk
       n - do not stage this hunk
       q - quit; do not stage this hunk or any of the remaining ones
       a - stage this hunk and all later hunks in the file
       d - do not stage this hunk or any of the later hunks in the file
       g - select a hunk to go to
       / - search for a hunk matching the given regex
       j - leave this hunk undecided, see next undecided hunk
       J - leave this hunk undecided, see next hunk
       k - leave this hunk undecided, see previous undecided hunk
       K - leave this hunk undecided, see previous hunk
       s - split the current hunk into smaller hunks
       e - manually edit the current hunk
       p - print the current hunk
       ? - print help
+
After deciding the fate for all hunks, if there is any hunk
that was chosen, the index is updated with the selected hunks.
+
You can omit having to type return here, by setting the configuration
variable `interactive.singleKey` to `true`.

diff::

  This lets you review what will be committed (i.e. between
  `HEAD` and index).


EDITING PATCHES
---------------

Invoking `git add -e` or selecting `e` from the interactive hunk
selector will open a patch in your editor; after the editor exits, the
result is applied to the index. You are free to make arbitrary changes
to the patch, but note that some changes may have confusing results, or
even result in a patch that cannot be applied.  If you want to abort the
operation entirely (i.e., stage nothing new in the index), simply delete
all lines of the patch. The list below describes some common things you
may see in a patch, and which editing operations make sense on them.

--
added content::

Added content is represented by lines beginning with "{plus}". You can
prevent staging any addition lines by deleting them.

removed content::

Removed content is represented

Title: Git Interactive Patch Editing
Summary
The git interactive mode allows users to add untracked files, choose patches to stage, and edit hunks, with options to stage, skip, or quit, and also provides a diff review of changes to be committed, as well as the ability to manually edit patches in an editor, with guidelines on how to edit added and removed content.