从远程服务器复制一个不包含版本记录(不包括.git和.gitignore文件)的git仓库

9
如何直接从远程服务器复制git存储库而不包含.git目录和.gitignore文件? 事先从标签名称或分支中选择。

2个回答

14
您可以使用该命令。
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)

谢谢。我正在寻找类似于last命令的东西(git archive --remote=url branchname | (cd otherpath; tar x))。但是这个不起作用。例如,以下内容不起作用: git archive --remote=git@github.com:gihanshp/WordPress-Widget-Boilerplate.git master| cd /tmp/ - gihan
你尝试过使用 'git archive branchname | (cd otherpath; tar x)' 吗? - Sergey K.
我正在尝试直接从远程服务器复制。 - gihan
1
首先使用“git clone”命令创建本地副本,然后再使用上述命令。 - Sergey K.
2
@gihan,请查看这个答案:使用--depth 1 - Bruno
显示剩余2条评论

0

我不知道这是否有帮助,但我的方法是使用递归的scp命令,忽略隐藏文件:

scp -r {git_directory}/* {target_directory}

例如:

scp -r /local/yourProjectGit/* user@machine:/home/user/dist

scp -r /local/yourProjectGit/* /local/youtProyect/dist

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接