LoginSignup
43
41

More than 5 years have passed since last update.

任意のリビジョンのファイルを別名で保存する方法(Git)

Last updated at Posted at 2013-01-28

gitでgit checkout <commit> -- <file>で任意のリビジョンに戻せることは知っていたのですが、「別名で保存したい時ってどうやってやるんだろう?」と前から思っていました。(ググっても欲する情報にヒットしない...)
で、やっとわかったので折角なのでアウトプットしておきます。

git cat-file blob <commit>:<file>

これで標準出力に出力されますので、ファイルにリダイレクトすればOK!

git cat-file blob git cat-file blob e4426a7:.vimrc > vimrc_e4426a7

まぁしかし、これ結構使いそうなのに入門書とかに載ってないよねぇー不思議。
大抵はgit diffを使うっていうのはあるけど...

追記

git show <commit>:<file>

これでもできた。(thanks to @k_takata)

43
41
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
43
41