Sourtree无法拉取,域名地址无法访问,ip可以访问?

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_36868342/article/details/82772382

叁念


场景一:

局域网内,在使用sourceTree拉取gitHub项目时发现无论如何都无法拉取,原先以为是gitHub项目地址错了,可核对地址后发现没错。后来发现将项目地址的域名更改为实际ip地址就能够拉取。
如原先github项目地址为:http://git.sannian.local/sannian/sannian-service-center.git
更改为:http://192.168.110.112/sannian/sannian-service-center.git

场景二:

在访问公司局域网域名时,如www.sannian.local 时候发现一直无法访问,更换ip地址后发现能访问到页面,如:192.168.110.112

解决方式

上诉场景其实也说明了解决方法,其实就是讲域名地址更换为对应的ip地址即可,但是如果你的项目拉多了,难道每个地址都需要将地址更改吗?何况域名地址比较容易记忆,ip地址说实在不舍和长时间记忆,那该怎么办?

这里提供的解决方式就是修改本机host文件
在此路径下找到你的host文件(注意:如果修改时提示无法保存,请先复制到其他盘进行修改):

C:\Windows\System32\drivers\etc

我们可以看到文件内容如下:

# Copyright (c) 1993-2009 Microsoft Corp.
#
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
#
# This file contains the mappings of IP addresses to host names. Each
# entry should be kept on an individual line. The IP address should
# be placed in the first column followed by the corresponding host name.
# The IP address and the host name should be separated by at least one
# space.
#
# Additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a '#' symbol.
#
# For example:
#
#      102.54.94.97     rhino.acme.com          # source server
#       38.25.63.10     x.acme.com              # x client host

# localhost name resolution is handled within DNS itself.
#	127.0.0.1       localhost
#	::1             localhost

我们只需要在文件末尾加入你需要进行映射的地址和域名即可,最好点击保存(部分机型需要重启电脑后生效),如下:

202.108.22.5 www.baidu.com
即
ip地址 域名地址

猜你喜欢

转载自blog.csdn.net/qq_36868342/article/details/82772382
今日推荐