git git的确切`svn export`等效命令?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6538668/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Exact `svn export` equivalent command for git?
提问by knocte
There is no exactsvn export
equivalent command for git? Really?
git没有完全svn export
等效的命令吗?真的吗?
Beware: this is not a duplicate question. That is, I already know and have tested these commands:
当心:这不是一个重复的问题。也就是说,我已经知道并测试了这些命令:
git clone --depth 1
<- Still downloads the .git folder.git checkout-init
<- Doesn't work for a remote repo, it works with a working copy (so you need to clone first).git archive
<- This would be the perfect solution, because it has a--remote
argument, but it only has 2 possible formats: tar or zip, so I would need to untar/unzip after downloading, and for that I need a pipe (|), but I'm on windows!! (not *n?x)git clone --bare
<- I still don't know what the heck this is, but it's not what I need.
git clone --depth 1
<- 仍然下载 .git 文件夹。git checkout-init
<- 不适用于远程存储库,它适用于工作副本(因此您需要先克隆)。git archive
<- 这将是完美的解决方案,因为它有一个--remote
参数,但它只有 2 种可能的格式:tar 或 zip,所以我需要在下载后解压/解压,为此我需要一个管道 (|),但是我在窗户上!!(不是 *n?x)git clone --bare
<- 我仍然不知道这是什么鬼东西,但这不是我需要的。
Please enlighten me is there a real svn export
replacement in git?
请赐教我svn export
git中有真正的替代品吗?
采纳答案by Vladimir Sosnin
At some hostings like GitHub you can make exact svn export
.
在 GitHub 等一些托管平台上,您可以将svn export
.
Example:
例子:
svn export https://github.com/GNOME/banshee/branches/master
Even partial! (some subpart of the repository)
甚至偏!(存储库的某个子部分)
Example:
例子:
svn export https://github.com/liferay/liferay-portal/branches/6.1.x/tools
For your own repository you should create some GitHub repository and add it as a remote:
对于您自己的存储库,您应该创建一些 GitHub 存储库并将其添加为远程:
git remote add github https://github.com/<user>/<repo>.git
then
然后
git push github <branch>
Now you able to do a partial checkout as above.
现在您可以像上面那样进行部分结帐。
回答by Bruno
From How do I do a quick clone without history revisions?:
git clone --depth 1 your_repo_url
Then, from the rmdir documentation:
然后,从rmdir 文档:
rd /s /q .git
回答by Dan Ray
The question "how can I do a svn-style 'export' with git?" is like asking "How can I change the tires on my basketball?". You can't, but that's not the basketball's fault. Yes it is rubber and full of air, but the similarity ends there.
问题“我怎样才能用 git 做一个 svn 风格的‘导出’?” 就像问“我怎样才能更换我的篮球轮胎?”。你不能,但这不是篮球的错。是的,它是橡胶的,充满空气,但相似之处到此为止。
You only need "export" with svn because it pollutes every single subdirectory with a .svn directory. Git doesn't do that, so you really don't need it. A clone IS an export, just with one directory at the root dir that all the repository business lives in.
您只需要使用 svn 进行“导出”,因为它会用 .svn 目录污染每个子目录。Git 不这样做,所以你真的不需要它。克隆是一种导出,仅在所有存储库业务所在的根目录中有一个目录。
The easiest thing is to clone the repo and then just delete the .git directory from the top level of the repo. Do that, and it's not a repo anymore, it's just a stand-alone directory of files.
最简单的方法是克隆 repo,然后从 repo 的顶层删除 .git 目录。这样做,它不再是一个 repo,它只是一个独立的文件目录。
Or, you know, ignore git all together and just use the files you cloned down. That works too.
或者,您知道,一起忽略 git,只使用您克隆的文件。这也有效。
回答by KingCrunch
Just get rid of the repository within the working copy.
只需摆脱工作副本中的存储库。
git clone remote
rm -Rf .git
(On Windows, it's rd /s /q
. Thanks for the hint by @Bruno.)
(在 Windows 上,它是rd /s /q
。感谢@Bruno 的提示。)
回答by Raoul
For your I still don't know what the heck this is: git clone --bare
will clone the repository without a working copy. This is usually done on a central repository so as to minimise disk space usage.
对于您,我仍然不知道这是什么鬼:git clone --bare
将在没有工作副本的情况下克隆存储库。这通常在中央存储库上完成,以最大限度地减少磁盘空间使用。
Bruno / King Crunch have the best answer. Although you could use git bash / cygwin to allow you to pipe if you need a one-liner.
Bruno / King Crunch 给出了最好的答案。尽管您可以使用 git bash / cygwin 来允许您在需要单线时使用管道。
回答by ghoti
Re your point, git archive <- This would be the perfect solution ...but it only has 2 possible formats: tar or zip, you can add new formats using documentation from the EXAMPLES section of the git-archive(1)
man page:
回到你的观点,git archive <- 这将是完美的解决方案......但它只有 2 种可能的格式: tar 或 zip,您可以使用git-archive(1)
手册页示例部分的文档添加新格式:
git config tar.tar.xz.command "xz -c"
Configure a "tar.xz" format for making LZMA-compressed tarfiles.
You can use it specifying --format=tar.xz, or by creating an output
file like -o foo.tar.xz.
While being "on windows" is generally considered an impediment to many tasks, with a little extra work, you can almost catch up to the folks running other operating systems by using software like Cygwinor MKS Toolkit.
虽然“在 Windows 上”通常被认为是许多任务的障碍,但只需做一些额外的工作,您几乎可以通过使用Cygwin或MKS Toolkit等软件赶上运行其他操作系统的人。
If after confirming that whatever command you need is available from within your shell, this sort of git config …
command still doesn't work for you, then you should perhaps post additional details about your configuration in a question on SuperUser.com.
如果在确认您的 shell 中可以使用您需要的任何命令后,这种git config …
命令仍然对您不起作用,那么您或许应该在SuperUser.com上的问题中发布有关您的配置的其他详细信息。
回答by Amr Mostafa
From https://stackoverflow.com/a/160719/43597
来自https://stackoverflow.com/a/160719/43597
git checkout-index -a -f --prefix=/destination/path/