使用 GIT 从 Windows 机器克隆到 Linux Web 服务器(内部)

发布于 2024-12-11 04:48:37 字数 582 浏览 0 评论 0原文

好的,我正在寻找一种使用 GIT 来使我的本地计算机(git 存储库)和我的网站(存储库的 git 克隆)之间的网站保持最新的方法。

我已经初始化了存储库(在 Windows 7 计算机上)并将所有文件添加到本地计算机上的存储库中。我现在需要将存储库获取到 webswerver(基于 Linux 的机器)。我可以通过 putty 和 ssh 访问网络服务器。如何将存储库克隆到适当的目录中以服务于网站?

我在基于 Linux 的机器上尝试了以下操作: git clone git+ssh://[电子邮件受保护]/d/webserver/htdocs/repo

我不断收到与主机 10.1.0.35 端口 22 的连接:连接超时

两台计算机都在内部,网络服务器正在运行在不同 IP 范围的网络外部(在防火墙)。我来自 subversion,可以轻松地在网络服务器和我的机器之间进行 svn 提交/更新,没有任何问题。

感谢您对此的任何指导!

OK, I am looking for a way to use GIT to keep a web site up to date between my local machine (git repository) and my web site (git clone of repository).

I have initialized the repository (on windows 7 machine) and added all the files to the repo on my local machine. I now need to get the repo to the webswerver (a linux-based machine). I can access the webserver via putty and ssh. How do I go about cloning the repo into the appropriate directory to serve the web site?

I have tried the following from my linux based machine: git clone git+ssh://[email protected]/d/webserver/htdocs/repo

I keep receiving a connect to host 10.1.0.35 port 22: connection time out

Both machines are in house with the webserver being outside of the network on a different IP range (outside of firewall). I came from subversion and can easily svn commit/update to and from the webserver and my machine without issue.

Thanks for any guidance on this!

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

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

发布评论

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

评论(5

闻呓 2024-12-18 04:48:37

我找到的最好的资源位于 在这里

我遇到的问题是,使用上述建议从 *nix 环境发出 git 克隆无法正确找到存储库的路径。

我可以通过使用 --base-path 和 --export-all 参数启动 git 守护进程来解决这个问题。

因此,从 windows 盒子:

git daemon --base-path=C:/source/ --export-all

然后从 *nix 盒子(在我的例子中是 mac):

git clone git://<local ip>/<project name>

我在 windows 盒子上的目录结构是:

c:\source\<project name> - this is where the .git folder lives

The best resource I've found for doing this is located here.

The problem I had was that issuing a git clone from the *nix environment using the above suggestions was unable to find the path to the repo properly.

I was able to fix this by starting the git daemon with the --base-path and --export-all params.

So, from the windows box:

git daemon --base-path=C:/source/ --export-all

Then from the *nix box (mac in my case):

git clone git://<local ip>/<project name>

My directory structure on the windows box is:

c:\source\<project name> - this is where the .git folder lives
苹果你个爱泡泡 2024-12-18 04:48:37

这是其他人所做的演练。它一步一步地展示如何做你想做的事。

Here is a walkthrough someone else did. It goes step by step showing how to do what you want.

吹梦到西洲 2024-12-18 04:48:37

IP 地址 10.1.0.135 是为专用网络保留的,这意味着它仅在家庭网络中使用时指代您的本地 Windows 计算机。如果您在服务器上使用该地址运行 git clone 命令,则 10.1.0.135 指的是完全不同的计算机,这解释了连接不起作用的原因。

我的建议是:不要尝试在家庭计算机上克隆存储库,而是首先在服务器上创建一个空存储库

server$ git init /path/to/repository

,然后将更改从您的计算机推送到服务器的存储库。

home$ git remote add website ssh://myuser@server/path/to/repository
home$ git push website

如果需要,您可以将远程名称称为“网站”以外的名称。

对于稍微更高级的用法,我编写了 博客文章解释了如何设置临时和生产服务器并使用 git 维护它们。不过,如果您不想使用临时服务器,我还链接到一些关于使用 git 管理网站的简单双存储库设置的教程,这基本上就是您正在寻找的内容。

The IP address 10.1.0.135 is reserved for private networks, which means that it only refers to your local Windows computer when used within your home network. If you're running the git clone command with that address on your server, 10.1.0.135 refers to a completely different computer, which explains why the connection isn't working.

Here's my suggestion: instead of trying to clone the repository on your home computer, first create an empty repository on the server

server$ git init /path/to/repository

and then push changes from your computer to the server's repository

home$ git remote add website ssh://myuser@server/path/to/repository
home$ git push website

You can call the remote something other than "website" if you want.

For slightly more advanced usage, I've written a blog post explaining how to set up staging and production servers and maintain them with git. If you don't want to deal with a staging server, though, I also link to a couple of tutorials about a simple two-repository setup to manage a website with git, which is basically what it sounds like you're looking for.

情定在深秋 2024-12-18 04:48:37

听起来您的 Windows 7 计算机(特别是端口 22)可能无法从防火墙外部访问。通过 Subversion,两台机器都可以访问网络服务器。此外,您的 Windows 计算机的 IP 是不可路由的 IP,这意味着您的防火墙也可能对您的内部网络进行 NAT。

您可以通过在防火墙中打开端口 22 或在防火墙中设置端口转发以指向您的 Windows 计算机来解决此问题。但是您可能应该在服务器上创建 git 存储库,然后从该存储库克隆到您的 Windows 计算机。您可以使用 scp -r 在服务器上获取初始存储库,尽管具有更多 git 经验的人可能会告诉您更好的方法。

Sounds like your windows 7 machine (in particular, port 22) may not be accessible from outside of the firewall. With subversion, the webserver is likely accessible to both machines. Also, the IP for your Windows machine is a non-routable IP, which means your firewall is likely also NAT'ing your internal network.

You could approach this by opening port 22 in the firewall, or setting up port-forwarding in the firewall to point to your Windows machine. But you should probably create the git repo on the server, then clone from that to your Windows machine instead. You could use scp -r to get that initial repo on the server, though someone with more git experience may be able to tell you a better way.

十年九夏 2024-12-18 04:48:37

如果您无论如何都需要将其签入版本控制系统,那么使用 Git 来完成此操作是个好主意。

只是想提一下,您还可以查看 rsync 实用程序 - 例如,谷歌“Rsync Windows”会带来一些不错的结果。

Rsync 专门用于保持目录树在计算机之间保持同步。它做得很聪明,不传输另一端已经存在的文件,并且您可以使用压缩..它具有大量功能,
通常用于 UNIX 生产环境。还有一些方法可以在 Windows 上运行它。

无论如何:

检查两台计算机上的防火墙设置 - 相关端口需要打开。在你的情况下,端口 22 可能被阻止

Good idea to do this with Git, if you need to check it into a version control system anyhow.

Just wanted to mention you could also look at the rsync utility - e.g. google "Rsync Windows" brings up some nice results.

Rsync is specifically made for keeping directory trees in-sync across machines. And it does it smart, not transfering files which are already on the other side, and you can use compression.. it has tons of features,
and is typically used in UNIX production environments. There are ways to run it also on Windows.

In any case:

Check your firewall settings on both machines - the relevant ports need to be open. In your case port 22 is probably blocked

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