← TechnologyThe essentials of

Git restore: make the source and destination explicit

Publisher: ResumeMaker • 1 source

Published: 22 Oct 2026 16:11 · Updated: 22 Oct 2026 16:11

AI source check: 22 Oct 2026 14:04. This is not editorial approval.

In a few sentences

In brief

git restore restores selected paths in the working tree or index. With --staged, the default source is HEAD; otherwise, working files normally use the index as their source.

Useful to know

git restore restores selected paths in the working tree or index. With --staged, the default source is HEAD; otherwise, working files normally use the index as their source. [1]

These modes are not interchangeable. Inspect the diff and establish which contents must survive. Restore can replace an uncommitted edit; it is not merely another way to display an old version.

Sources

For further detail and to check the information:

  1. [1] Git - git-restore Documentation ↗