From cfce5c6a4ee0c8c5e7f9bed1cf135c728b0f16eb Mon Sep 17 00:00:00 2001 From: jbranchaud Date: Wed, 22 Feb 2017 20:37:56 -0600 Subject: [PATCH] Add Viewing A File On Another Branch as a git til --- README.md | 3 ++- git/viewing-a-file-on-another-branch.md | 17 +++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 git/viewing-a-file-on-another-branch.md diff --git a/README.md b/README.md index a65ecc8..f6e7ddc 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ variety of languages and technologies. These are things that don't really warrant a full blog post. These are mostly things I learn by pairing with smart people at [Hashrocket](http://hashrocket.com/). -_506 TILs and counting..._ +_507 TILs and counting..._ --- @@ -158,6 +158,7 @@ _506 TILs and counting..._ - [Untrack A Directory Of Files Without Deleting](git/untrack-a-directory-of-files-without-deleting.md) - [Untrack A File Without Deleting It](git/untrack-a-file-without-deleting-it.md) - [Verbose Commit Message](git/verbose-commit-message.md) +- [Viewing A File On Another Branch](git/viewing-a-file-on-another-branch.md) - [What Changed?](git/what-changed.md) - [What Is The Current Branch?](git/what-is-the-current-branch.md) - [Whitespace Warnings](git/whitespace-warnings.md) diff --git a/git/viewing-a-file-on-another-branch.md b/git/viewing-a-file-on-another-branch.md new file mode 100644 index 0000000..79e2a33 --- /dev/null +++ b/git/viewing-a-file-on-another-branch.md @@ -0,0 +1,17 @@ +# Viewing A File On Another Branch + +Sometimes you want to view a file on another branch (without switching +branches). That is, you want to view the version of that file as it exists +on that branch. `git show` can help. If you branch is named `my_feature` and +the file you want to see is `app/models/users.rb`, then your command should +look like this: + +``` +$ git show my_feature:app/models/users.rb +``` + +You can even tab-complete the filename as you type it out. + +See `man git-show` for more details. + +[source](http://stackoverflow.com/questions/7856416/view-a-file-in-a-different-git-branch-without-changing-branches)