I have the file "main.cpp
" open in my editor.
I want to see the previous revision of "main.cpp
" in the editor too.
The way I do it now is like this.
close "main.cpp" in the editor
prompt> mv main.cpp tmp
prompt> git checkout HEAD^ main.cpp
prompt> mv main.cpp old_main.cpp
prompt> mv tmp main.cpp
prompt>
open "main.cpp" and "old_main.cpp" in the editor
Can it be simplified, so I don't have to close "main.cpp" in the editor?
What I'm hoping for is a variant of git-checkout
that can do this.
UPDATE: im using git on mac osx 10.5.7
prompt> git --version
git version 1.6.0.4
prompt>
UPDATE2: Jakub Narębski answer is:
prompt> git show HEAD^:dir1/dir2/dir3/main.cpp > old_main.cpp
prompt>