From e116e1bf5420ddc42c9a98c7aec22c99e171447f Mon Sep 17 00:00:00 2001 From: jbranchaud Date: Tue, 22 Sep 2015 22:24:39 -0500 Subject: [PATCH] Add Grab A Single File From A Stash as a git til. --- README.md | 1 + git/grab-a-single-file-from-a-stash.md | 17 +++++++++++++++++ 2 files changed, 18 insertions(+) create mode 100644 git/grab-a-single-file-from-a-stash.md diff --git a/README.md b/README.md index 337b9d8..12cc7e9 100644 --- a/README.md +++ b/README.md @@ -38,6 +38,7 @@ smart people at [Hashrocket](http://hashrocket.com/). - [Determine The Hash Id For A Blob](git/determine-the-hash-id-for-a-blob.md) - [Dry Runs in Git](git/dry-runs-in-git.md) - [Excluding Files Locally](git/excluding-files-locally.md) +- [Grab A Single File From A Stash](git/grab-a-single-file-from-a-stash.md) - [Ignore Changes To A Tracked File](git/ignore-changes-to-a-tracked-file.md) - [Intent To Add](git/intent-to-add.md) - [Last Commit A File Appeared In](git/last-commit-a-file-appeared-in.md) diff --git a/git/grab-a-single-file-from-a-stash.md b/git/grab-a-single-file-from-a-stash.md new file mode 100644 index 0000000..d471805 --- /dev/null +++ b/git/grab-a-single-file-from-a-stash.md @@ -0,0 +1,17 @@ +# Grab A Single File From A Stash + +In git, you can reference a commit SHA or branch to checkout differing +versions of files. + +```bash +$ git checkout d3d2e38 -- README.md +``` + +In the same way, you can snag the version of a file as it existed in a +stash. Just reference the relevant stash. + +```bash +$ git checkout stash@{1} -- README.md +``` + +[source](http://stackoverflow.com/questions/1105253/how-would-i-extract-a-single-file-or-changes-to-a-file-from-a-git-stash)