【问题标题】:Create a copy of each version of a file in a git repository在 git 存储库中创建文件的每个版本的副本
【发布时间】:2017-08-25 08:28:55
【问题描述】:

我想将InterestingFile.cpp 的每个提交版本复制到一个目录。

目标文件应将其提交时间戳作为文件名(如/tmp/AllVersions/1495035445

以下示例有效,但需要 helper.sh 脚本。如何在没有帮助脚本的情况下写一行?

$ git rebase -i --exec "~/helper.sh ~/InterestingFile.cpp" --preserve-merges 0123ABCD


$ cat ~/helper.sh  
#!/bin/bash
TIMESTAMP=`git show -s --format=%ct HEAD` 
cp $1 /tmp/AllVersions/${TIMESTAMP}


$ ls -1 /tmp/AllVersions  # here are the files finally
1499951860
1500038126
1500040256
1500363092

【问题讨论】:

    标签: git bash command-line


    【解决方案1】:
    git rebase -i --exec "cp ~/InterestingFile.cpp /tmp/AllVersions/$(git show -s --format=%ct HEAD)" --preserve-merges 0123ABCD
    

    【讨论】:

      猜你喜欢
      • 2012-06-28
      • 2019-08-03
      • 2018-04-30
      • 2016-11-01
      • 2015-05-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-08-06
      相关资源
      最近更新 更多