search

Home  >  Q&A  >  body text

如何提取 git 中某个文件的所有版本并按顺序命名好

如题,我想将 git 里某个文件的所有版本文件全部都复制一份打包,但是不知道从何入手,有什么好的办法呢?

伊谢尔伦伊谢尔伦2778 days ago605

reply all(3)I'll reply

  • 高洛峰

    高洛峰2017-04-24 09:13:56

    I don’t know what you want to name it. Let me make the simplest version, with additional submission value:

    git log --follow --pretty=format:%H vimrc | xargs -I{} sh -c 'git show {}:vimrc > vimrc.{}'
    

    reply
    0
  • 天蓬老师

    天蓬老师2017-04-24 09:13:56

    git log --follow file
    

    You can get the commits of all historical versions of this file.

    Based on this information, you can write a script to extract the file contents of each version and then package them.

    reply
    0
  • 阿神

    阿神2017-04-24 09:13:56

    Refer to @Evian’s answer

    git log --follow --pretty=format:%H README.md|awk '{print "git show "":README.md > README.md."NR"."}'|sh
    

    reply
    0
  • Cancelreply