TarkaLabs TIL
Published in

TarkaLabs TIL

Fetching a Single File From Git Stash

A lot of times when jumping across branches on your Git repository, you’ll come across situations where you need to un-stash a single file from your stashes. Though there is no specific command to achieve this, there are workarounds that can be used to achieve this behavior in Git.

Checking Out a Single File From The Stash

This method will checkout the file from the stash into your working branch. Ensure that there are no local uncommitted changes on the existing file that you do not wish to lose before using this method as it will restore the version of the file as of the time when the stash was performed.

git checkout stash@{0} -- <filename>

Creating a Copy of a Stashed File Under a Different Filename

This is a non-destructive method that will let you recreate the file in the stash into the working branch under a new filename.

git show stash@{0}:stashed_file.rb > copy_of_stashed_file.rb

The stash tool can be used in conjunction with other git features to achieve desired outcomes. I would recommend checking out Atlassian’s documentation on Git Stashing:



Tarka Labs is a team of passionate hackers, designers and product managers. We believe in experimental methods to identify the best solutions to problems instead of working on technology du jour. (https://tarkalabs.com/)

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Sreedev Kodichath

Senior Software Engineer @ Tarka Labs. Ruby, Elixir, Javascript C & Rust. Amateur Radio Operator — KD2ZWB/VU2JWE. www.sree.dev. Brooklyn, NYC.