【问题标题】:Is there a single git command to retrieve an old version of a file?是否有一个 git 命令来检索文件的旧版本?
【发布时间】:2014-08-15 21:16:24
【问题描述】:

在 git 中,我们可以使用 git show commitlike:filepath 来显示文件在特定版本中的状态,并且使用 shell 重定向我们可以检索该版本并将其放回工作树的某个位置:git show commitlike:filepath > otherpath

是否有一个 git 命令来执行后一项任务? git checkout commitlike -- filename 可以检索文件,但只能将其放在其原始位置。

【问题讨论】:

标签: git sh


【解决方案1】:
$ git config --global alias.getfile '!sh -c '"'"'git show $1:$2 > $3'"'"' -'

那么你可以这样做:

$ git getfile COMMITLIKE FILE_PATH DESTINATION_FILE

例如:

$ git getfile HEAD~3 .gitignore old_gitignore

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-01-02
    • 2011-08-10
    • 1970-01-01
    • 1970-01-01
    • 2021-03-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多