Stage changes and commit
Choose exactly which edits go into a commit, down to a single block of lines, then commit them or fix up the commit you made a moment ago.
What staging is
Git does not commit every edit automatically. You first stage the edits you want. Staged edits wait in a holding area until you commit; everything else stays in your working tree for a later commit. This lets you split one afternoon of mixed edits into several tidy commits.
A hunk is one block of neighbouring changed lines in a file. A file with edits in three places has three hunks, and you can stage each one separately.
The changes panel
The panel on the right groups files by state:
| Group | What is in it |
|---|---|
| Conflicted | Files with merge conflicts. See Resolve conflicts. |
| Staged | Changes that go into the next commit. |
| Unstaged | Changes to files Git already tracks, not yet staged. |
| Untracked | New files Git has never seen. |
A group only appears when it has files. A file with some hunks staged and some not appears in both Staged and Unstaged.
Each file has a letter badge:
| Badge | Meaning |
|---|---|
M | Modified |
A | Added |
D | Deleted |
R | Renamed |
C | Copied |
T | File type changed |
U | Unmerged (in conflict) |
? | Untracked |
Stage whole files
- To stage one file, select the plus button on its row (Stage).
- To stage everything, select Stage all on the Unstaged or Untracked heading. Either one stages every change in the working tree, new files included.
- To take a file back out, select the minus button on its row under Staged (Unstage), or Unstage all on the heading.
Unstaging never changes the file on disk. It only removes the change from the next commit.
Stage one hunk at a time

- 1State — Shows whether this diff is UNSTAGED, STAGED or UNTRACKED.
- 2File history — Opens every commit that touched this file.
- 3Stage file — Stages the whole file. Space does the same.
- 4Stage hunk — Stages only this block of changes.
- 5Changed lines — Added lines are green with a plus, removed lines are red with a minus.
- 6Selected file — The file whose diff is shown.
Select a file under Unstaged. Its diff opens in the middle of the window.
Read the hunks. Each one starts with a header such as
@@ -1,8 +1,14 @@, which gives the line numbers before and after.Select Stage hunk on each hunk you want in the next commit.
The file now also appears under Staged. Select it there to review what you staged. Each hunk in that view has an Unstage hunk button.
A new, untracked file is shown as one diff of added lines. Binary files show Binary file instead of a diff.
TIP
With a file's diff open, press Space to stage or unstage the whole file. The key is ignored while you are typing in a text field, so a space in your commit message stays a space.
Write the commit
Type a one-line summary in Commit subject. The counter beside it shows the length against 72 characters, a common limit that keeps subjects readable in logs.
Optionally explain why in Description (optional).
Select Commit, or press Ctrl + Enter. The button shows the number of staged files, for example Commit (2).
The button stays disabled until there is a subject and something staged. The counter turns amber past 50 characters and red past 72.
Amend the last commit
Amending replaces the most recent commit with a corrected one. Use it for a typo in the message or a file you forgot.
Stage any extra changes you want to add. Skip this to change only the message.
Turn on Amend in the commit box. If the subject and description are empty, the previous commit's message is filled in for you. Text you already typed is kept.
Edit the message if needed.
Select Amend.
WARNING
Amending rewrites the commit. If you already pushed it, the server still has the old one, and you would need a force push to replace it. Avoid amending commits that other people may have pulled. See Fetch, pull and push.
Look at one file's history
In the diff view, select the File history button (the clock icon). A dialog lists every commit that changed the file, with author and date, and shows the diff for the one you select. The history follows renames, so it continues past the point where the file had another name.
Next steps
- Branch and merge
- Interactive rebase: tidy commits after the fact.
- Shortcuts and reference