DevTools/Git
[Git] Restore Command
llHoYall
2020. 10. 23. 21:47
This command restores working tree files.
This command is experimental. (v2.29.0)
Description
Restore specified paths in the working tree with some contents from a restore source.
If a path is tracked but does not exist in the restore source, it will be removed to match the source.
Usage
Restore Specified Paths
$ git restore <pathspec>
Specify the Restore location
If neither option is specified, by default the working tree is restored.
Specifying both restores both.
$ git restore -W <pathspec>
$ git restore --worktree <pathspec>
$ git restore -S <pathspec>
$ git restore --staged <pathspec>
Restore with Rebase or Merge
When restoring files in the working tree from the index, use stage #2(ours) or #3(theirs) for unmerged paths.
Note that during git rebase and git pull --rebase, ours and theirs may appear swapped.
$ git restore --ours <pathspec>
$ git restore --theirs <pathspec>
Restore with SubModule
$ git restore --recurse-submodules
$ git restore --no-recurse-submodules
Never Remove Files when Restoring
$ git restore --overlay
$ git restore --no-overlay