Site Tools


wiki:git-staging

Table of Contents

Git Staging

Staging is where you prepare changes before committing. Use git add to stage files, then git commit to save them as a snapshot. Staging lets you pick which files go into each commit, so you can commit logically related changes together and keep unrelated changes separate.

$ git add file.txt           # stage a single file
$ git add .                  # stage all changes in the directory
$ git reset file.txt         # unstage a file
$ git diff                   # view unstaged changes
$ git diff --staged          # view staged changes

You can modify files, stage some, then modify them again. Only the staged changes go into the commit; unstaged changes remain in your working directory. This flexibility lets you keep your commits clean and focused.

wiki/git-staging.md · Last modified: (external edit)