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.
Written by Filipe Kiss
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Checkout file from branch
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#