본문 바로가기
DevTools/Git

[Git] Restore Command

by llHoYall 2020. 10. 23.

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

'DevTools > Git' 카테고리의 다른 글

[Git] Tip: Revert Merged Commit  (0) 2021.03.05
[Git] Tip: Change committer and author from already committed commit  (0) 2021.02.15
[Git] Switch Command  (0) 2020.10.23
[Git] Config Command  (0) 2020.09.23
[Git] Getting Started  (0) 2020.09.23

댓글