Last Updated: February 25, 2016
· filipekiss

Checking out specific files from another branch

Today, at work, we needed to checkout an archive from another branch from the same repo. Sometimes you need to retrieve or update just one file from another branch and don't want to merge everything, you can just checkout the file.

So, let's say you're in ~/projects/your-project at master branch and need to checkout some_file.js from your new-feature branch. Just type in the following:

git checkout new-feature -- some_file.js

There you go. You just checked out the revision you needed. Just add and commit the file and you're good to go.