| Category | git |
| Added on | 2026-03-17 |
| Source | source |
After git 2.23:
$ git restore --source otherbranch path/to/myfile.txt
Works on folders too!
Alternatives:
$ git checkout otherbranch -- path/to/myfile.txt, adds also to staging area$ git show otherbranch:path/to/myfile.txt > path/to/myfile.txt, does not work in Windows