无法克隆git repo un EC2 iNSTANCE

时间:2018-12-27 06:16:40

标签: amazon-ec2 git-clone

我使用以下命令尝试克隆存储库,但不幸的是弹出以下错误。我不能再走了

ubuntu@ip-add-rr-ee-ss:~$ git clone https://github.com/repo/file.git

Cloning into 'file'... fatal: unable to access 'https://github.com/repo/file.git/': Could not resolve host: github.com

2 个答案:

答案 0 :(得分:0)

  

无法解析主机

这一定是由于EC2实例上的DNS问题引起的(我可以在这里看到您正在使用Ubuntu)

  1. 您可以先尝试使用curl测试与该URL的连接
  2. 检查DNS配置:cat /etc/resolv.conf
  3. 如果可能,您 应该用 google 之类的其他DNS替换您当前的DNS设置 (8.8.8.8&8.8.4.4)
  4. 尝试编辑该文件:vi /etc/resolv.conf
  5. 你 应该将以下内容插入/编辑:
    名称服务器8.8.8.8
    域名服务器8.8.4.4
  6. 通过单击[Esc]并输入:wq来保存文件

答案 1 :(得分:0)

将以下内容添加到我的组安全设置的出站连接中后,我便解决了该问题:

class Example:
    def __init__(self, start, end):
        self.start = start
        self.end = end
        self.resume_point = 0
    def __iter__(self):
        return self
    def __next__(self):
        if self.resume_point == 0:
            # simulates the beginning of your generator function
            self.num = self.start
            # simulates checking the `while` loop condition
            if self.num <= self.end:
                # next time we should continue from the `yield`
                self.resume_point = 1
                # `return` simulates pausing the generator function
                return self.num
            # simulates the end of your generator function
            self.resume_point = 2
            raise StopIteration
        elif self.resume_point == 1:
            # simulates continuing from the `yield` in your generator function
            self.num += 1
            # simulates checking the `while` loop condition
            if self.num <= self.end:
                # redundant, but it shows what happens
                self.resume_point = 1
                # `return` simulates pausing the generator function
                return self.num
            # simulates the end of your generator function
            self.resume_point = 2
            raise StopIteration
        elif self.resume_point == 2:
            # simulates resuming from after your generator function returned
            self.resume_point = 2
            raise StopIteration

这也解决了我的sudo yum安装问题。