If you are in one branch, and need to just copy a file that exists in another branch, then you can use the command:
git checkout otherbranch <relative_file_path>
Of course, if there is a remote repo then otherbranch
needs to be fetched and up to do date. Or you can checkout from the remote repo, like this:
git checkout origin/otherbranch <relative_file_path>
You can also pull from a specific commit, like so:
git checkout <commit_hash> <relative_file_path>
More details and variations here: http://stackoverflow.com/questions/307579/how-do-i-copy-a-version-of-a-single-file-from-one-git-branch-to-another
© 2016 Dave Hein
This work by Dave Hein is licensed under a Creative Commons Attribution 4.0 International License.