Copying a file from a different git branch

Nov 13, 2017

Sometimes one has to copy a file from one branch to another. The git checkout command comes in handy in this situation. Let's say we need to copy a file named from source-branch to destination-branch. First make sure you're in the destination-branch. Then apply git checkout to copy the target file.

> git checkout destination-branch
> git checkout sourche-branch path/to/target/file