转自http://blog.chinaunix.net/uid-15174104-id-3809952.html
引自:http://stackoverflow.com/questions/18062403/cannot-ping-google-com-from-ubuntu-terminal-behind-a-proxy-server
ping 了一天的网络,由于有代理proxy,都没有ping通,后来发现stackOverflow上的一个回答:
The usual reason for a proxy server is to isolate internal machines, and force them out through a central point in order to manage bandwidth, content and/or security concerns. Organizations who employ this mechanism will often disable routes from internal machines directly outside.
In this configuration, you are not truly connected to the
wget
http_proxy
--proxy-user
--proxy-password
ping
ping
我们先来认识一下Git的三个最重要的配置文件,他们分别是/etc/gitconfig,${HOME}/.gitconfig,
/etc/gitconfig: 系统范围内的配置文件,适用于系统所有的用户; 使用
git config 时, 加 --system 选项,Git将读写这个文件。
${HOME}/.gitconfig: 用户级的配置文件,只适用于当前用户; 使用
git config 时, 加 --global 选项,Git将读写这个文件。
.git/config: Git项目级的配置文件,位于当前Git工作目录下,只适用于当前Git项目; 使用 git config 时,不加选项(
--system 和 --global ),Git将读写这个文件。
每个级别的配置都会覆盖( override )上层的相同配置,覆盖的顺序是
- $ git config --file .git/config user.name
# 查阅项目配置信息里的用户信息。 - $
git config --file .git/config user.name "Harrison F" # 将用户信息配置到项目的配置文件中。
- harrison@ubuntu:~$ git config --global --list
- fatal: unable to read config file '/home/harrison/.gitconfig': No such file or directory
- harrison@ubuntu:~$ git config --system --list
- fatal: unable to read config file '/etc/gitconfig': No such file or directory
- 用户信息(user.*)
首先,需要配置的是你的用户名和Email地址。这两条配置非常重要,每次 Git 提交时都会引用这两条信息,说明是谁提交了更新,所以会随更新内容一起被永久纳入历史记录。
$ git config --global user.name " Harrison F"
$ git config --global user.email harrison.f@gmail.com
使用了--global 选项,所以,这些信息将被写入 ${HOME}/.gitconfig 中; 如果在特定的项目中,要使用其他的用户名或者Email地址,只需重新配置时去掉 --global 选项,新的信息将被写入 .git/config 中。 设置完这两条基本信息后,你应该可以提交更新了,但是为了让我们更方便的使用Git,我们还有几个重要的信息需要配置。 Git会在 需要你输入一些额外消息的时候自动调用一个外部文本编辑器给你使用。 默认会使用操作系统指定的默认编辑器,一般可能会是 Vi 或者 Vim。如果你有其他偏好,比如 Gedit的话,可以重新设置:
- 文本编辑器(core.editor)
$ git config --global core.editor gedit
如果这个信息不配置,那么你与Git交互时,所有字体的颜色都将是默认系统的一个颜色,很难看,而也不方便我们看出更新和变化。
- 字体颜色(color.*)
$ git config --globalcolor.ui auto
$ git config --globalcolor.status auto
$ git config --globalcolor.branch auto
$ git config --globalcolor.diff auto
$ git config --globalcolor.interactive auto
差异分析工具是用来解决合并冲突的,Git将在出现合并冲突时自动调用配置好的差异分析工具。
- 差异分析工具(merge.tool)
$ git config --global merge.tool vimdiff# 使用Vimdiff作为差异分析工具
一般在公司内想要获取互联网上的Git项目,都要求设置HTTP代理。这里将设置最简单的HTTP代理。
- 配置代理(http.proxy)
$ git config --global http.proxy http://proxy.companyname.com:8080/
好了,我们这里学习最基本的Git配置和git config命令基本的用法。那么我们如果想删除一些不想要的配置怎么办呢?最直接办法就是编辑配置文件,但是这里还有更简单的命令来删除不想要的配置 信息。
了解上面的这几个部分,那么git config就算基本掌握了,已经可以应付平常的使用。如果想要深入了解git config,请看git config的帮助手册。$
- 删除配置配置信息
git config --unset user.name # 删除具体的一条配置信息 (user.name="xxxxxx"将被删除)
$ git config --remove-section user# 删除一组配置信息 (user组的所有配置都将被删除)
$ git config# 简短的帮助信息
$ git config --help# 详细的帮助手册