gpt4 book ai didi

git - 克隆裸 git 存储库的单个路径

转载 作者:太空狗 更新时间:2023-10-29 14:34:57 25 4
gpt4 key购买 nike

我正在尝试将提交后 Hook 添加到裸存储库,这样无论何时进行提交,更改的文件都会自动安装在(硬编码)目录中。

有没有办法从存储库中获取单个文件?

git-clone 似乎不允许指定路径,我发现的任何其他命令(git-fetch、git-pull)似乎都需要现有的本地 git 存储库才能工作。

有办法吗?

最佳答案

您可以使用 git show 从裸存储库中的任何修订中提取单个文件, 使用语法 git show <rev>:<filename> ,例如:

 $ ls branches  config  description  HEAD  hooks  info  objects  packed-refs  refs $ git show master:COPYING > /tmp/COPYING $ head -5 /tmp/COPYING                     GNU GENERAL PUBLIC LICENSE                        Version 3, 29 June 2007  Copyright (C) 2007 Free Software Foundation, Inc.   Everyone is permitted to copy and distribute verbatim copies

a couple of examples in the git-show(1) man page .希望对您有所帮助。

关于git - 克隆裸 git 存储库的单个路径,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1361110/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com