如何直接从远程服务器复制git存储库而不包含.git目录和.gitignore文件? 事先从标签名称或分支中选择。
git archive branchname
从指定的目录树中归档文件。例如,您可以将输出传递给tar
来打包文件或过滤像.gitignore
这样的文件(.git
不会被导出):
git archive branchname | tar -x -C c:\git-my-branch
查看git help archive
以获取更多详细信息。
在现有仓库中,相当于svn export . otherpath
的命令是:
git archive branchname | (cd otherpath; tar x)
svn export url otherpath
的等价命令是
git archive --remote=url branchname | (cd otherpath; tar x)
我不知道这是否有帮助,但我的方法是使用递归的scp命令,忽略隐藏文件:
scp -r {git_directory}/* {target_directory}
例如:
scp -r /local/yourProjectGit/* user@machine:/home/user/dist
scp -r /local/yourProjectGit/* /local/youtProyect/dist