从远程服务器复制没有修订版(没有.git和.gitingore)的git存储库

gih*_*han 8 git

如何在没有.git目录和.gitignore文件的情况下直接从远程服务器复制git存储库?提前从标签名称或分支.

Ser*_* K. 14

您可以使用该命令

git archive branchname
Run Code Online (Sandbox Code Playgroud)

从命名树中归档文件.即你可以传递输出来tar打包文件或过滤文件,如.gitignore(.git不会被导出):

git archive branchname | tar -x -C c:\git-my-branch
Run Code Online (Sandbox Code Playgroud)

结帐出git help archive更多的细节.

相当于svn export . otherpath现有仓库内部的是

git archive branchname | (cd otherpath; tar x)
Run Code Online (Sandbox Code Playgroud)

相当于svn export url otherpathIS

git archive --remote=url branchname | (cd otherpath; tar x)
Run Code Online (Sandbox Code Playgroud)

  • @gihan,见[这个答案](http://stackoverflow.com/a/6538833/372643):使用`--depth 1`. (2认同)