如何使我的本地存储库可用于 git-pull?

发布于 2024-07-23 10:55:52 字数 997 浏览 7 评论 0原文

我有一个工作副本存储库,我一直在使用它,没有任何问题; 该存储库的来源位于 GitHub 上。

我想让我的工作副本存储库作为我的构建机器(另一个物理主机上的虚拟机)的来源,以便我对工作副本所做的提交可以在构建机器上构建和测试,而无需通过首先是 GitHub。 我已经为 GitHub 存储库构建了一个版本,但我希望这是一个“黄金”存储库/构建; 也就是说,如果那里发生了一些事情,那么针对 GitHub 的构建应该可以保证通过。

我查看了有关 Git URL 的文档,发现可以选择使用 git://host.xz[:port]/path/to/repo.git/ 形式的 URL (例如,请参阅 git-clone 文档)。 我想以最简单的方式、最少的配置来完成此操作:我不想仅仅为了将其发布到我的构建机器而设置 SSH 守护程序或 Web 服务器。

我运行的是 Windows 7 x64 RC,安装了 MSysGit 和 TortoiseGit,并且在防火墙上打开了 Git 的默认端口 (9814)。 请假设工作副本存储库位于 D:\Visual Studio Projects\MyGitRepo,主机名为 devbox。 构建机器是Windows Server 2008 x64。 我一直在构建机器上尝试以下命令以及相关的输出:

D:\Integration>git clone "git://devbox/D:\Visual Studio Projects\MyGitRepo"
Initialized empty Git repository in D:/Integration/MyGitRepo/.git/
devbox[0: 192.168.0.2]: errno=No error
fatal: unable to connect a socket (No error)

我错过了什么吗?

I have a working copy repository that I've been working in no problem; the origin for this repository is on GitHub.

I'd like to make my working copy repository available as the origin for my build machine (a VM on another physical host), so that commits I make to my working copy can be built and tested on the build machine without having to go via GitHub first. I already have a build for the GitHub repository going, but I'd like this to be a "golden" repository/build; i.e., if something goes in there, the build against GitHub should be guaranteed to pass.

I've looked at the documentation on Git URLs, and see that there's the option of using a URL in the form git://host.xz[:port]/path/to/repo.git/ (see, e.g., git-clone documentation). I want to do this in the simplest possible way, with the minimum of configuration: I don't want to have to set up an SSH daemon or web server just to publish this to my build machine.

I'm running Windows 7 x64 RC, I have MSysGit and TortoiseGit installed, and I have opened Git's default port (9814) on the firewall. Please assume working copy repo is at D:\Visual Studio Projects\MyGitRepo, and the hostname is devbox. The build machine is Windows Server 2008 x64. I have been trying the following command on the build machine, with the associated output:

D:\Integration>git clone "git://devbox/D:\Visual Studio Projects\MyGitRepo"
Initialized empty Git repository in D:/Integration/MyGitRepo/.git/
devbox[0: 192.168.0.2]: errno=No error
fatal: unable to connect a socket (No error)

Am I missing something?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

缱倦旧时光 2024-07-30 10:55:52

设置用于拉取的存储库有五种可能性:

  • 本地文件系统git clone /path/to/repogit clone file://path/to /repo。 如果您有网络文件系统,但网络使用效率不高,则工作量最少。 (这几乎正是 Joakim Elofsson 提出的解决方案)
  • HTTP 协议< /strong>: git 克隆 http://example.com/repo。 您需要任何 Web 服务器,并且还需要运行(可能通过挂钩自动运行)git-update-server-info 到通过“哑”协议生成获取/拉取所需的信息。
  • SSHgit clone ssh://example.com/srv/git/repogit clone example.com:/srv/git/repo >。 您需要设置 SSH 服务器(SSH 守护进程),并在客户端上安装 SSH(例如 MS Windows 上的 PuTTY)。
  • git协议git克隆git://example.com/repo。 您需要运行 git-daemon; 有关详细信息,请参阅文档(您可以将其作为独立进程运行,仅用于获取,不必作为服务运行)。 git-daemon 是 git 的一部分。
  • 捆绑:您可以使用 git-bundle 命令移动对象和引用,以任何方式(甚至通过 USB)将其传输到客户端计算机,并使用 git 克隆文件进行克隆。 bndl (如果克隆不起作用,您可以执行“git init”,“git remote add”和“git fetch”)。

您的示例中缺少的可能是在服务器上运行 git-daemon 。 那,或者错误配置 git-daemon。

不幸的是,我无法帮助您在 MS Windows 上将 git-daemon 作为服务运行。 不过,在最新版本的 msysGit 公告中,没有任何关于 git-daemon 无法工作的信息。

Five possibilities exist to set up a repository for pull from:

  • local filesystem: git clone /path/to/repo or git clone file://path/to/repo. Least work if you have networked filesystem, but not very efficient use of network. (This is almost exactly solution proposed by Joakim Elofsson)
  • HTTP protocols: git clone http://example.com/repo. You need any web server, and you also need to run (perhaps automatically, from a hook) git-update-server-info to generate information required for fetching/pulling via "dumb" protocols.
  • SSH: git clone ssh://example.com/srv/git/repo or git clone example.com:/srv/git/repo. You need to setup SSH server (SSH daemon), and have SSH installed on client (e.g. PuTTY on MS Windows).
  • git protocol: git clone git://example.com/repo. You need to run git-daemon on server; see documentation for details (you can run it as standalone process only for fetching, not necessary run as service). git-daemon is a part of git.
  • bundle: You generate bundle on server using git-bundle command, transfer it to a client machine in any way (even via USB), and clone using git clone file.bndl (if clone does not work, you can do "git init", "git remote add" and "git fetch").

What you are missing in your example is probably running git-daemon on server. That, or misconfiguring git-daemon.

Unfortunately I cannot help you with running git-daemon as service on MS Windows. There is nothing in announcement for last version of msysGit about git-daemon not working, though.

小姐丶请自重 2024-07-30 10:55:52

除了 Jakub Narębski 的答案之外,还有另一种更符合您原来问题的答案。 您可以像平常一样从 github 克隆,然后当您想从本地存储库执行一次性拉取时,只需执行以下操作:(

git pull /path/to/repo master

您可以输入任何分支名称,而不是 master 。)

In addition to Jakub Narębski's answers, there is anotherway, more in-line with your original question. You could clone from github like you usually do, then when you want to perform a one-off pull from your local repo, just do this:

git pull /path/to/repo master

(instead of master you can put any branch name.)

傲鸠 2024-07-30 10:55:52

如果您有类似的路径

C:\Project\

并且您已经执行了 git init ,那么您还有一个文件夹

C:\Project\.git\

您现在创建一个新文件夹

C:\.git\

进入该文件夹并运行 git clone --bare ..\Project (裸露很重要),
返回到您的 C:\Project\ 文件夹并执行 git remote add-url local ..\.git\Project
现在,您只需执行 git add -A 、 git commit -m "HelloWorld" 和 git Push local master 即可。

您可以共享 Project 文件夹,将其连接到 Z: 并执行 git clone Z:\Project - 您现在可以使用 git pull origin mastergit push origin master 将更改从一台计算机推送/拉取到另一台计算机。

If you have a path like

C:\Project\

and you did git init already, so you also have a folder

C:\Project\.git\

You now make a new folder

C:\.git\

Go into that folder and run git clone --bare ..\Project (bare is important),
go back to your C:\Project\ folder and do a git remote add-url local ..\.git\Project.
Now you just do git add -A, git commit -m "HelloWorld" and git push local master.

You may share the Project folder, connect it to Z: and do git clone Z:\Project - you can use now git pull origin master and git push origin master to push/pull changes from one computer to another.

笑梦风尘 2024-07-30 10:55:52

ssh 路由运行良好,但需要远程 ssh 服务器。 如果您有 Windows 平台,那么 Cygwin 提供了一个可与 Git 配合使用的 ssh 服务器,但如果使用 Cygwin Git,请手动升级 Git(我在 http://alecthegeek.wordpress.com/2009/01/21/top-tip-upgrade-git-on-cygwin/ )。

The ssh route works well but does require a remote ssh server. If you have Windows platform then Cygwin provides a working ssh server that works with Git, but manually upgrade Git if using Cygwin Git (I wrote some hints at http://alecthegeek.wordpress.com/2009/01/21/top-tip-upgrade-git-on-cygwin/).

窗影残 2024-07-30 10:55:52

我最近更改了我的一个 git 项目,使用 sitecopy 将自身复制到 HTTP 服务器来执行实际的文件上传。

这非常简单,只需使用 git update-server-info 然后将 .git 目录镜像到服务器上的某个可通过 http 访问的目录即可。 我使用了相当常见的“project.git”。

来自 http://site/project-git 的 Git pull 工作起来就像冠军一样,我不需要尽管 sitecopy 也支持 webdav,但服务器上除了 FTP 访问之外还有其他任何内容。

但是,我不建议使用 sitecopy,因为它不能很好地保持多台计算机同步。 对于我的项目,HTTP 存储库是只读的,并且黄金更新仅来自一台机器,因此它运行良好。

I recently changed one of my git projects to replicate itself to an HTTP server using sitecopy to do the actual file uploads.

It's pretty easy, just use git update-server-info then mirror the .git directory to some http-accessible directory on your server. I used 'project.git', which is fairly common.

Git pull from http://site/project-git works like a champ, and I don't have to have anything on the server except FTP access, though sitecopy supports webdav as well.

I don't recommend using sitecopy, however, as it doesn't keep multiple machines in sync well. For my project, the HTTP repository is readonly, and gold updates come from just one machine, so it works well enough.

私藏温柔 2024-07-30 10:55:52

如果您的远程主机位于同一个 Windows 网络中,即您可以通过 \remotehost 访问它,
然后你可以在资源管理器中映射网络驱动器,比方说 z: --> \remotehost\repodir,
之后您可以使用“git clone /z/myproject”来克隆项目

If your remote host is in the same windows network, i.e. you can access it as \remotehost,
then you can map network drive in explorer, let's say z: --> \remotehost\repodir,
after that you can use 'git clone /z/myproject' to clone project

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文