Stage chosen content
#add copies current file content into the index. Later edits remain unstaged. add -p lets you review hunks.
Fragment
Stage by intent; git add . can include unrelated work.
Reference
Inspect, save, combine and recover work with clear command effects.
Modern Git CLI, including switch and restore (Git 2.23+). Independent examples use illustrative paths and branch names. Inspect status and diffs before changing files or history. Commands below are reference material, not executed by this guide.
add copies current file content into the index. Later edits remain unstaged. add -p lets you review hunks.
Fragment
Stage by intent; git add . can include unrelated work.
restore --staged restores the index from HEAD by default. The working file keeps its edits.
Fragment
Effect: index changes; working tree and branch history stay as they were.
commit records the index as a new commit and advances the current branch. Unstaged changes and untracked files are not included.
Fragment
--amend creates a replacement commit from the current index, normally retaining the old message with --no-edit.
Fragment
Commit identity changes. Coordinate before replacing history already used by others.