How to Checkout a File from Another Branch
Sometimes you’re working on a feature branch and you’ve modified a file after a few commits but suddenly realize that you want to restore the base branch version of that file.
Do you checkout the base branch and copy that file so you can paste it into your feature branch? No, there’s an easier way!
git checkout <YOUR_BASE_BRANCH> -- some_file.txt
Although the example here assumes that you need the version of a file from a branch that you’ve based your current branch on, that’s not actually a requirement. You can use this command to checkout a version of a file from any other branch you’d like!