gpt4 book ai didi

Git:仅 check out 没有存储库的文件?

转载 作者:IT王子 更新时间:2023-10-29 00:55:27 27 4
gpt4 key购买 nike

我只想 checkout 没有 .git 文件和整个存储库的文件。这是因为我想用 git 管理网站(php 和 html),我正在寻找一种简单的方法来从存储库更新 htdocs 文件夹中的文件,而无需公开存储库。 (现在它在主目录中,可以通过 ssh 访问,但我必须手动将新文件放入 htdocs。

最佳答案

git-archive联机帮助页包含以下示例:

git archive --format=tar --prefix=junk/ HEAD | (cd /var/tmp/ && tar xf -)

Create a tar archive that contains the contents of the latest commit on the current branch, and extract it in the '/var/tmp/junk' directory.

或者你可以使用低级别 git-checkout-index ,其中联机帮助页包含以下示例:

Using git checkout-index to "export an entire tree"

The prefix ability basically makes it trivial to use 'git checkout-index' as an "export as tree" function. Just read the desired tree into the index, and do

   $ git checkout-index --prefix=git-export-dir/ -a

git checkout-index will "export" the index into the specified directory.

The final "/" is important. The exported name is literally just prefixed with the specified string.

或者你可以尝试使用 --work-tree 选项到 git wrapper,或者 GIT_WORK_TREE 环境变量,例如通过使用“git --work-tree=/somwehere/else checkout -- .”。

关于Git:仅 check out 没有存储库的文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2866358/

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