Git:仅检出没有存储库的文件? [英] Git: Checkout only files without repository?
问题描述
我想只检出没有.git文件和整个存储库的文件。这是因为我想用git管理一个网站(php& html),而且我正在寻找一种简单的方法来更新存储库中htdocs文件夹中的文件,而无需公开存储库。 (现在它在home-dir中,并通过ssh访问,但我必须手动将新文件放到htdocs中。 解决方案
git-archive 联机帮助页包含以下内容例如:
lockquote
$ g $ git archive --format = tar --prefix = junk / HEAD |(cd / var / tmp /&& tar xf - )
创建一个包含最新内容的tar归档提交到当前分支,并将其提取到'/ var / tmp / junk'目录中。
或者你可以使用低级 git-checkout -index ,其中手册页包含以下示例:
使用git checkout-index导出整个树 h2>
前缀能力基本上使得使用'
git checkout-index
'作为导出为树功能变得微不足道。只需将所需的树读入索引,并执行
$ git checkout-index --prefix = git-export-dir / -a
git checkout-index
will导出索引到指定的目录。
最后的/很重要。导出的名字实际上只是以指定的字符串为前缀。
或者您可以尝试使用 - 工作树
选项以git包装或GIT_WORK_TREE环境变量,例如通过使用 git --work-tree = / somwehere / else checkout - 。
。
i'd like to just checkout the files without the .git files and the whole repository. It's because i'd like to manage a website (php & html) with git and i'm looking for an easy way to update the files in the htdocs folder from the repository, without having the repository public. (now it's in the home-dir and is accessed via ssh, but i have to put the new files to htdocs manually.
The git-archive manpage contains the following example:
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.
Or you can use low level git-checkout-index, which manpage contains the following example:
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.
Or you can try to use --work-tree
option to git wrapper, or GIT_WORK_TREE environment variable, e.g. by using "git --work-tree=/somwehere/else checkout -- .
".
这篇关于Git:仅检出没有存储库的文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!