mirror of
https://github.com/jbranchaud/til
synced 2026-01-03 23:28:02 +00:00
Add Viewing A File On Another Branch as a git til
This commit is contained in:
17
git/viewing-a-file-on-another-branch.md
Normal file
17
git/viewing-a-file-on-another-branch.md
Normal file
@@ -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)
|
||||
Reference in New Issue
Block a user