1

Often, when doing refactoring work in branch "Y" using git, I think to myself -- How was this done in branch "X"? My local repo's in no place for a checkin -- and stashing so that I can switch branches, inspect the file in the other branch and then switch back (trying not to forget to stash pop) in the process seems way too hacky. Is there a way to get a handle on the file in another branch so that I can display it next to the version in my current branch?

My editor is emacs if that makes any difference. The ideal solution would give me a separate emacs buffer for the file in branch "X" -- But I realize that might be asking too much. Even something as simple as a hypothetical git cat myfile otherbranch would be helpful.

mgilson
  • 300,191
  • 65
  • 633
  • 696
  • Try http://stackoverflow.com/questions/7856416/in-git-view-a-file-in-a-different-branch-without-changing-branches – mohit6up Feb 14 '13 at 14:40
  • @mohit6up -- exactly what I wanted. Thanks. I voted to close this as a duplicate -- you should too. I thought about just deleting it, but I thought someone else might find this easier on a google search. – mgilson Feb 14 '13 at 14:43
  • @ALL -- Please vote to close this as recommended [here](http://meta.stackexchange.com/questions/157389/is-there-any-value-to-not-deleting-my-own-duplicate-question) – mgilson Feb 14 '13 at 14:46
  • good idea. I'm afraid it'll have to be others as I don't think I have the privilege. – mohit6up Feb 14 '13 at 14:55
  • There may be some way to do this via `git cat-file` ... but I don't really understand the `man` page. – mgilson Feb 14 '13 at 14:59
  • I added [an Emacs-specific answer](http://stackoverflow.com/a/14886215/113848) to that other question. – legoscia Feb 14 '13 at 23:55

0 Answers0