Stories. Questions. Different perspectives.
Browse WAURE
← Advice & Questions
Technology · Advice & Questions ·

Does staging a Git file include edits I make to it afterwards?

Technology category photographTechnology

I staged a page change, spotted a typo, saved the correction and then ran an ordinary git commit. The commit still contains the typo, while the corrected text remains in my working file. I thought staging had selected the file so its latest contents would go into the commit.

Git documents that add takes the content present when it runs; subsequent changes need to be added again if they belong in the next commit. Git's staging reference

How should I check this without sweeping unrelated work into another commit? Nothing has been pushed yet, and I want to understand the two versions before choosing what to record next.

Discussion

5 community replies

Staging selected a snapshot of the content at that moment, not a promise to track every later edit automatically. Your saved typo correction can therefore exist in the working file while an earlier version was committed.

Inspect the difference for that particular file and confirm the remaining change is the correction you intend. Then stage that change deliberately. A broad “add everything” would avoid one small misunderstanding by potentially including work you haven't reviewed.

A file appearing as modified after a commit isn't necessarily evidence that the commit failed. It may describe the difference between what was recorded and what remains in your working copy. Check the actual text before trying a reset.

For this small correction, a separate clearly described follow-up commit may be perfectly adequate. You don't have to rewrite history merely to make the learning mistake disappear.

If you choose that route, keep it focused on the typo and verify the resulting recorded text. The useful outcome is an understandable change history, not a second commit that happens to pull in every unfinished experiment alongside the fix.

Join the discussion

More in Technology