关于github 添加远程源的问题

21 views
Skip to first unread message

cloudaice

unread,
Feb 23, 2012, 11:56:42 PM2/23/12
to GotGit
我们知道git支持三种访问协议,以hello work版本库为例子;我们可以使用下面的三种方法clone版本库

* HTTP协议: `https://github.com/gotgithub/helloworld.git`
* Git协议: `git://github.com/gotgithub/helloworld.git`
* SSH协议: `ssh://g...@github.com/gotgithub/helloworld.git`

但是当我们添加远程版本库的时候:是否也是可以用下面这样的语句呢?
$ git remote add origin g...@github.com:gotgithub/helloworld.git
$ git remote add origin https://github.com:gotgithub/helloworld.git
$ git remote add origin git://github.com/gotgithub/helloworld.git

我有一次添加了https的远程源,我就没有办法使用gitpush进行推送了,问题听复杂的……
我想知道这三种协议在我们使用的时候,具体有那些不同,以及需要注意什么?

Larry Cai

unread,
Feb 24, 2012, 12:45:24 AM2/24/12
to got...@googlegroups.com
git:// 协议是只读的,缺省应该是不能push (写的)

https:// 会有防火墙问题,不太清楚具体原因。

我在公司访问github和自己的gerrit都是用 git@ 方式(ssh协议)的。

rgs/larry


--
您收到这封邮件是因为您订阅了 Google Groups "GotGit" 邮件组。
向邮件组发言很简单,发送邮件到: got...@googlegroups.com 即可。
如果不想继续收到相关邮件,发送退订邮件到 gotgit+un...@googlegroups.com
您也可以通过 Web 界面访问和配置本邮件列表:
http://groups.google.com/group/gotgit?hl=en?hl=en



--
True software development embraces consistent inconsistency.
blog: http://codeslife.com

Jiang Xin

unread,
Feb 24, 2012, 1:43:40 AM2/24/12
to GotGit

On Feb 24, 1:45 pm, Larry Cai <larry.ca...@gmail.com> wrote:
> git:// 协议是只读的,缺省应该是不能push (写的)
>
> https:// 会有防火墙问题,不太清楚具体原因。

https 协议根据架设方式不同:哑协议/智能协议,是否开启webdav,是否开启认证等等,决定
了是否支持 push。

> 我在公司访问github和自己的gerrit都是用 git@ 方式(ssh协议)的。
>
> rgs/larry
>

在 2012年2月24日 下午12:56,cloudaice <clou...@gmail.com> 写道:
> 我想知道这三种协议在我们使用的时候,具体有那些不同,以及需要注意什么?

使用什么协议要根据服务器提供什么协议来确定呀。要是都提供了,首先要选智能协议,
不要哑协议,慢。

如果不支持push,可以另外配置 remote.origin.pushurl 设置推送地址。

Larry Cai

unread,
Feb 24, 2012, 1:52:05 AM2/24/12
to got...@googlegroups.com
学习了,弱弱地问:什么是 哑协议/智能协议 ?

--
您收到这封邮件是因为您订阅了 Google Groups "GotGit" 邮件组。
向邮件组发言很简单,发送邮件到: got...@googlegroups.com 即可。
如果不想继续收到相关邮件,发送退订邮件到 gotgit+un...@googlegroups.com
您也可以通过 Web 界面访问和配置本邮件列表:
http://groups.google.com/group/gotgit?hl=en?hl=en

Jiang Xin

unread,
Feb 24, 2012, 2:18:10 AM2/24/12
to got...@googlegroups.com
在 2012年2月24日 下午2:52,Larry Cai <larry...@gmail.com> 写道:
> 学习了,弱弱地问:什么是 哑协议/智能协议 ?

哑协议(dumb protocol)。例如 HTTP 协议在没有 CGI 程序做辅助时,就是
哑协议。哑协议的架设非常简单,只要把 Git 裸版本库仍到 Web 服务器中即可,
是否开放目录浏览均可。然后就可以使用 git 克隆版本库。

使用哑协议用 Git 克隆版本库,服务器端不会启动任何应用应答 Git 客户端请求,
都要靠 Git 客户端自己去取。

- 通过 .git/info/refs 获取引用列表及最新指向
- 通过 .git/objects/info/packs 获取打包文件文件名
- Git客户端根据需要到 http 服务器中逐一下载文件
- 如果恰巧需要的对象被打包,对不起要下载整个包!

为了保证哑协议文件和版本库的一致性,要更新相关文件。可以从 .git/hooks/post-update
钩子脚本中看到执行命令 git update-server-info ,就是干这个用的。

--
蒋鑫

北京群英汇信息技术有限公司
邮件: worldhe...@gmail.com
网址: http://www.ossxp.com/
博客: http://www.worldhello.net/
微博: http://weibo.com/gotgit/
电话: 010-51262007, 18601196889

Chunlin Zhang

unread,
Feb 26, 2012, 8:32:54 PM2/26/12
to got...@googlegroups.com
2012/2/24 Larry Cai <larry...@gmail.com>:

> git:// 协议是只读的,缺省应该是不能push (写的)
我记得 git:// 也是可以配置成可写的
>
> https:// 会有防火墙问题,不太清楚具体原因。
这个多半是 gfw 的原因吧

Larry Cai

unread,
Feb 26, 2012, 9:03:04 PM2/26/12
to got...@googlegroups.com
git://  可以配置成可写,不过那是自寻烦恼 ;-)

--
您收到这封邮件是因为您订阅了 Google Groups "GotGit" 邮件组。
向邮件组发言很简单,发送邮件到: got...@googlegroups.com 即可。
如果不想继续收到相关邮件,发送退订邮件到 gotgit+un...@googlegroups.com
您也可以通过 Web 界面访问和配置本邮件列表:
http://groups.google.com/group/gotgit?hl=en?hl=en

Chunlin Zhang

unread,
Feb 26, 2012, 9:20:51 PM2/26/12
to got...@googlegroups.com
2012/2/27 Larry Cai <larry...@gmail.com>:
> git://  可以配置成可写,不过那是自寻烦恼 ;-)
嗯,没试过,我自用的是用 ssh,如果要公开就用 gerrit 吧

另外我也喜欢用 mercurial,随时一运行 hg serv 就有一个 http 可以推送的服务了

Reply all
Reply to author
Forward
0 new messages