How to recover a file from another branch in Git

Estimated 1 minute readย ยทย Tuesday, 25 January 2022
Copy
git show branch:filename.ext > path/to/file.ext

Where branch can be any ref including a branch name, tag, HEAD.

Thanks to this Stack Overflow reference.

We use essential cookies to make our site work. With your consent, we may also use non-essential cookies to improve user experience and analyze website traffic. By clicking 'Accept', you agree to our website's cookie use as described in our Privacy Policy.