我可以在没有 git 的情况下下载 git 存储库吗?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/595088/
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
Can I download a git repository without git?
提问by Casey Rodarmor
I keep a lot of stuff in git repositories, out there on the net. The problem is that I often find myself on machines that don't have git, and where I also don't have root access. I don't necessarily need to commit changes back to the repo, just get the current master of the git project.
我在 git 存储库中保存了很多东西,在网上。问题是我经常发现自己在没有 git 的机器上,而且我也没有 root 访问权限。我不一定需要将更改提交回 repo,只需获取 git 项目的当前 master。
Is there any way to download a git repo, without having git itself? The ideal solution would be some kind of portable shell script.
有没有办法下载 git repo,而无需 git 本身?理想的解决方案是某种便携式 shell 脚本。
Thanks!
谢谢!
采纳答案by T.E.D.
It sounds like what you are looking for is something that will let you have a local working directory with your actual git repository remote.
听起来您正在寻找的是可以让您拥有一个本地工作目录和您的实际 git 存储库远程的东西。
Since that kinda goes against the git philsophy of always having your entire repository history local, I doubt you are going to find anything. Your best bet would probably be to just copy the sources from another git working directory via typical file copy methods (ftp a tarball, or whatever).
由于这有点违背始终将整个存储库历史记录在本地的 git 哲学,我怀疑您会找到任何东西。您最好的选择可能是通过典型的文件复制方法(ftp tarball 或其他方式)从另一个 git 工作目录复制源代码。
EDIT: OOC, does the git client actually requireadmin access to install for personal use? I understand needing admin to install one of the git servers, but the client should be OK with just user access. Try installing (or compiling from sources) just the client.
编辑:OOC,git 客户端是否真的需要管理员访问权限才能安装供个人使用?我知道需要管理员来安装其中一台 git 服务器,但是客户端应该可以只需要用户访问权限。尝试只安装(或从源代码编译)客户端。
回答by Peter Boughton
On the server with the git repository, create a shell script that exports and zips the code, then download that zip from the other machines.
在带有 git 存储库的服务器上,创建一个 shell 脚本来导出和压缩代码,然后从其他机器下载该 zip。
For example:
例如:
cd /pub/git/project.git
git archive --format=zip --prefix=project/ HEAD > /home/project/public_html/downloads/project-dev.zip
Also, to make this generate HEAD on-demand, use a server-side script to execute the shell script and provide the zip file for download.
此外,要使其按需生成 HEAD,请使用服务器端脚本执行 shell 脚本并提供 zip 文件以供下载。
Here's a basic CFML script that does this - but it can obviously be written in any server-side language.
这是一个执行此操作的基本 CFML 脚本 - 但它显然可以用任何服务器端语言编写。
<cfset OutputFilename = "#ProjectName#-dev.zip"/>
<cfexecute name="/home/project/latest.sh"/>
<cfheader name="Content-Disposition" value="inline; filename=#OutputFilename#"/>
<cfcontent file="./#OutputFilename#" reset type="application/zip"/><cfsetting showdebugoutput="false"/><cfabort/>
EDIT: The cgitweb interface to git supports this out of the box. View any commit and you can download a .zip, .tar.gz or a .tar.bz2
编辑:git的cgitweb 界面支持开箱即用。查看任何提交,您可以下载 .zip、.tar.gz 或 .tar.bz2
回答by EfForEffort
You can just scp(1) a git repository to your local machine, if you have ssh access to the machine on which the git repository resides. When you want to merge the history, you can scp the new repo back and merge.
如果您对 git 存储库所在的机器具有 ssh 访问权限,则您可以将 git 存储库 scp(1) 复制到您的本地机器上。当你想合并历史时,你可以 scp 新的 repo 并合并。