git 在 GitHub 上推送到远程指向一个新的服务器 IP

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/18265851/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 08:54:42  来源:igfitidea点击:

Push to remote on GitHub pointed to a new server IP instead

gitgithubssh

提问by cgmb

I've no idea what changed, but I was in for a big surprise when I tried to push to my remote on GitHub and it went to a completely unknown IP instead.

我不知道发生了什么变化,但是当我尝试在 GitHub 上推送到我的遥控器时,我大吃一惊,结果它转到了一个完全未知的 IP。

[slavik@localhost guardonce]$ git push origin master
Warning: Permanently added the RSA host key for IP address '192.30.252.128' to the list of known hosts.
Connection closed by 192.30.252.128
fatal: Could not read from remote repository.
Please make sure you have the correct access rights and the repository exists.

Other tests suggest that my local machine's configuration is fine. For example:

其他测试表明我本地机器的配置没问题。例如:

[slavik@localhost guardonce]$ ssh -T [email protected]
Hi slavik81! You've successfully authenticated, but GitHub does not provide shell access.

and

[slavik@localhost guardonce]$ git remote -v
origin  [email protected]:slavik81/guardonce.git (fetch)
origin  [email protected]:slavik81/guardonce.git (push)

Looking at my known_hosts, I expected to be speaking to github.com,204.232.175.90. So, why aren't I?

看看我的 known_hosts,我希望与github.com,204.232.175.90. 那么,我为什么不是呢?

回答by VonC

What has changed is now (August 25th, 2013) explained in "IP Address Changes":

现在(2013 年 8 月 25 日)在“ IP 地址更改”中解释了已更改的内容

We mentioned these new addresses back in Apriland updated the Meta APIto reflect them.
Some GitHub services have have already been migrated to the new addresses, including:

我们在 4 月份提到了这些新地址并更新了Meta API以反映它们。
一些 GitHub 服务已经迁移到新地址,包括:

api.github.com
gist.github.com
ssh.github.com

Our next step is to begin using these IP addresses for the main GitHub site, so we're reminding everyone about this change.
There are a few gotchas that might affect some people:

  • If you have explicit firewall rules in place that allow access to GitHub from your network, you'll want to make sure that all of the IP ranges listed in this article are included.

  • If you have an entry in your /etc/hostsfile that points github.comat a specific IP address, you should remove it and instead rely on DNS to give you the most accurate set of addresses.

  • If you are accessing your repositories over the SSH protocol, you will receive a warning message each time your client connects to a new IP address for github.com.
    As long as the IP address from the warning is in the range of IP addresses in the previously mentioned Help page, you shouldn't be concerned.
    Specifically, the new addresses that are being added this time are in the range from 192.30.252.0 to 192.30.255.255.
    The warning message looks like this:

我们的下一步是开始将这些 IP 地址用于 GitHub 主站点,因此我们提醒大家注意此更改。
有一些问题可能会影响某些人:

  • 如果您有明确的防火墙规则允许从您的网络访问 GitHub,您需要确保包含本文中列出的所有 IP 范围。

  • 如果您的/etc/hosts文件中有指向github.com特定 IP 地址的条目,您应该将其删除,而是依靠 DNS 为您提供最准确的地址集。

  • 如果您通过 SSH 协议访问您的存储库,每次您的客户端连接到github.com.
    只要警告中的 IP 地址在前面提到的帮助页面中的 IP 地址范围内,您就不必担心。
    具体来说,这次新增的地址范围是192.30.252.0到192.30.255.255。
    警告消息如下所示:

Warning: Permanently added the RSA host key for IP address '$IP' to the list of known hosts.

回答by suhailvs

check existing remote url

检查现有的远程 url

git config remote.origin.url

if it is not correct you can change it by:

如果不正确,您可以通过以下方式更改它:

git remote set-url origin [email protected]:slavik81/guardonce.git

回答by Srdjan Grubor

It's a github server in California

它是加利福尼亚的 github 服务器

$ git config remote.origin.url
[email protected]:blah/foo
$ ping github.com
PING github.com (192.30.252.128) 56(84) bytes of data.
64 bytes from 192.30.252.128: icmp_seq=1 ttl=47 time=63.6 ms

http://en.utrace.de/ip-address/192.30.252.128

http://en.utrace.de/ip-address/192.30.252.128

Edit: They've been under a heavy DDoS attack in the last few days so they probably did this to help fight it.

编辑:他们在过去几天遭受了严重的 DDoS 攻击,所以他们可能这样做是为了帮助对抗它。

回答by Bijendra

The url of git pushes are listed in config folder. Look for .git folder in you application and then open the config file inside it.

git pushes 的 url 列在 config 文件夹中。在您的应用程序中查找 .git 文件夹,然后打开其中的配置文件。

$ cat config 

[core] repositoryformatversion = 0 filemode = true bare = false logallrefupdates = true [remote "origin"] fetch = +refs/heads/*:refs/remotes/origin/* url = [email protected]:******/******.git [branch "master"] remote = origin merge = refs/heads/master [branch "sprint_1"] remote = origin merge = refs/heads/sprint_1

[core] repositoryformatversion = 0 filemode = true bare = false logallrefupdates = true [remote "origin"] fetch = +refs/heads/*:refs/remotes/origin/* url = [email protected]:******/******.git [branch "master"] remote = origin merge = refs/heads/master [branch "sprint_1"] remote = origin merge = refs/heads/sprint_1

Checkout the url for remote "origin", it shows the remote present url. You can make changes here.

检查远程“来源”的 url,它显示远程当前 url。您可以在此处进行更改。

回答by girishso

If you are deploying with capistranogem, it clones the repo in deploy_dir/shared/cached-copyon the server.

如果您使用capistranogem进行部署,它会将 repo 克隆deploy_dir/shared/cached-copy到服务器上。

Simply remove the deploy_dir/shared/cached-copydirectory.

只需删除deploy_dir/shared/cached-copy目录。

$ rm -rf deploy_dir/shared/cached-copy

$ rm -rf deploy_dir/shared/cached-copy

Then deploy again.

然后再次部署。