故事背景,svn与git各有长处,不过git大势所趋吧,那就搞搞。git的服务端,是基于phabricator搭建的,关于它的资料自行google就好了。其实之前运维已经搭好了phabricator了,也给过我叫做test的账号去试过了,只不过还有些问题没处理好,拖了一段时间后,我着手来弄一下。
1. 建diffusion
详细就不多说,diffusion名字叫swallowframework,很简单,也有教程。
第一次,没有分权限,所有人都可以visit, push
```
git clone http://phabricator.eelly.test/diffusion/SWALLOWFRAMEWORK/swallowframework.git eelly_swallow
```
代码可以正常拉取,没问题

第二次,将用户按项目分了组,只有php项目的人才能visit, push,将我自己加入到php项目里面去
```
git clone http://phabricator.eelly.test/diffusion/SWALLOWFRAMEWORK/swallowframework.git eelly_swallow
```
报错了!
```
fatal: unable to access 'http://phabricator.eelly.test/diffusion/SWALLOWFRAMEWORK/swallowframework.git/': The requested URL returned error: 403
```
一看这提示就是权限问题。当然是google啦,找来找去,phabricator上面的设置都是正常的。
又叫了在php项目的同事去拉代码。卧槽,他们是正常的,而且拉取的时候,会提示让他输入账号,密码,而我的拉取过程,根本就没有提示我去输入账号密码!
只能通过输出拉取的调试信息来看看问题在哪里了,使用的是GIT_CURL_VERBOSE=1
```
GIT_CURL_VERBOSE=1 git clone http://phabricator.eelly.test/diffusion/SWALLOWFRAMEWORK/swallowframework.git eelly_swallow
```
输出的详细信息如下
```
Cloning into 'eelly_swallow'...
* Couldn't find host phabricator.eelly.test in the .netrc file; using defaults
* Trying 172.18.107.96...
* TCP_NODELAY set
* Connected to phabricator.eelly.test (172.18.107.96) port 80 (#0)
> GET /diffusion/SWALLOWFRAMEWORK/swallowframework.git/info/refs?service=git-upload-pack HTTP/1.1
Host: phabricator.eelly.test
User-Agent: git/2.10.1 (Apple Git-78)
Accept: */*
Accept-Encoding: gzip
Pragma: no-cache

< HTTP/1.1 401 You must log in to access repositories.
< Server: nginx
< Date: Thu, 09 Mar 2017 13:59:26 GMT
< Content-Type: text/html; charset=utf-8
< Transfer-Encoding: chunked
< Connection: keep-alive
< WWW-Authenticate: Basic realm="Phabricator Repositories"
<
* Curl_http_done: called premature == 0
* Connection #0 to host phabricator.eelly.test left intact
* Couldn't find host phabricator.eelly.test in the .netrc file; using defaults
* Found bundle for host phabricator.eelly.test: 0x7ff01250c7c0 [can pipeline]
* Hostname phabricator.eelly.test was found in DNS cache
* Trying 172.18.107.96...
* TCP_NODELAY set
* Connected to phabricator.eelly.test (172.18.107.96) port 80 (#1)
> GET /diffusion/SWALLOWFRAMEWORK/swallowframework.git/info/refs?service=git-upload-pack HTTP/1.1
Host: phabricator.eelly.test
User-Agent: git/2.10.1 (Apple Git-78)
Accept: */*
Accept-Encoding: gzip
Pragma: no-cache

< HTTP/1.1 401 You must log in to access repositories.
< Server: nginx
< Date: Thu, 09 Mar 2017 13:59:26 GMT
< Content-Type: text/html; charset=utf-8
< Transfer-Encoding: chunked
< Connection: keep-alive
< WWW-Authenticate: Basic realm="Phabricator Repositories"
<
* Ignoring the response-body
* Curl_http_done: called premature == 0
* Connection #1 to host phabricator.eelly.test left intact
* Issue another request to this URL: 'http://phabricator.eelly.test/diffusion/SWALLOWFRAMEWORK/swallowframework.git/info/refs?service=git-upload-pack'
* Couldn't find host phabricator.eelly.test in the .netrc file; using defaults
* Found bundle for host phabricator.eelly.test: 0x7ff01250c7c0 [can pipeline]
* Re-using existing connection! (#1) with host phabricator.eelly.test
* Connected to phabricator.eelly.test (172.18.107.96) port 80 (#1)
* Server auth using Basic with user 'test'
> GET /diffusion/SWALLOWFRAMEWORK/swallowframework.git/info/refs?service=git-upload-pack HTTP/1.1
Host: phabricator.eelly.test
Authorization: Basic dGVzdDp0MTIzNDU2Nzg=
User-Agent: git/2.10.1 (Apple Git-78)
Accept: */*
Accept-Encoding: gzip
Pragma: no-cache

< HTTP/1.1 403 You do not have permission to access this repository.
< Server: nginx
< Date: Thu, 09 Mar 2017 13:59:26 GMT
< Content-Type: text/html; charset=utf-8
< Transfer-Encoding: chunked
< Connection: keep-alive
< Vary: Accept-Encoding
< Content-Encoding: gzip
<
* Curl_http_done: called premature == 0
* Connection #1 to host phabricator.eelly.test left intact
fatal: unable to access 'http://phabricator.eelly.test/diffusion/SWALLOWFRAMEWORK/swallowframework.git/': The requested URL returned error: 403
```
这里涉及的几次握手的过程就不详细解释了,大家用心看一下还是可以明白的。
重点关注这几行代码
```
* Ignoring the response-body
* Curl_http_done: called premature == 0
* Connection #1 to host phabricator.eelly.test left intact
* Issue another request to this URL: 'http://phabricator.eelly.test/diffusion/SWALLOWFRAMEWORK/swallowframework.git/info/refs?service=git-upload-pack'
* Couldn't find host phabricator.eelly.test in the .netrc file; using defaults
* Found bundle for host phabricator.eelly.test: 0x7ff01250c7c0 [can pipeline]
* Re-using existing connection! (#1) with host phabricator.eelly.test
* Connected to phabricator.eelly.test (172.18.107.96) port 80 (#1)
* Server auth using Basic with user 'test'
> GET /diffusion/SWALLOWFRAMEWORK/swallowframework.git/info/refs?service=git-upload-pack HTTP/1.1
Host: phabricator.eelly.test
Authorization: Basic dGVzdDp0MTIzNDU2Nzg=
User-Agent: git/2.10.1 (Apple Git-78)
Accept: */*
Accept-Encoding: gzip
Pragma: no-cache
```
这里的意思是,Ignoring the response-body,忽略响应的内容,Server auth using Basic with user 'test',直接用test这个账号去尝试登录。我在其它同事debug这个clone的过程,是没有这些步骤的,他们是,去到 WWW-Authenticate: Basic realm="Phabricator Repositories" 这一步的时候,就会显示输入账号密码的过程,怎么回事呢?为什么一直都是用test这个账号去尝试登录呢?
过程是很复杂的,反正也花了两个小时去找解决方案,也尝试了不同方法。最后在这里找到了头绪,http://git.vger.kernel.narkive.com/iW0NHyKd/git-https-transport-and-wrong-password
这文章里面关键点在于这些对话
```
1. Using a credential helper that supports secure long-term storage
(osxkeychain, wincred, etc).

2. Specifying the username to the credential subsystem explicitly, by
putting something like:

[credential "https://yourhost/"]
username = yourusername

in your git config.
```
意思是说,在你的git config里面,直接针对某个远程地址,设置账号,于是我改了一下自己的git配置
```
vim ~/.gitconfig
```
在后面加入
```
[credential "http://phabricator.eelly.test"]
username = xxxxxxx
```
再次进行拉取
```
GIT_CURL_VERBOSE=1 git clone http://phabricator.eelly.test/diffusion/SWALLOWFRAMEWORK/swallowframework.git eelly_swallow
```
这次就正常了,提示我输入密码,搞掂!从以上文章,大概联想了一下,应该是macOS的keychain保存了一些账号导致在clone的时候,默认使用了test这个账号去进行登录的,于是再看了下keychain里面的东西。真是无语了,果然是这样子


干脆一做二不休,直接将keychain对应的账号密码,由test改为我自己的账号密码,完成!

have fun with macOS & git!

[macOS] keychain的跳坑之旅!git拉取的权限问题的更多相关文章

  1. git拉取远程分支并创建本地分支和Git中从远程的分支获取最新的版本到本地

    git拉取远程分支并创建本地分支 一.查看远程分支 使用如下Git命令查看所有远程分支: git branch -r 二.拉取远程分支并创建本地分支 方法一 使用如下命令: git checkout ...

  2. git 拉取远程代码

    git 拉取远程代码 || 利用vscode编辑器自带了git,可在ctrl+~打开控制台拉取代码,非常好用哦~在实际项目开发过程中,往往是已经存在远程项目了,我们定义的需求是只需要简单的操作git, ...

  3. Git拉取项目时报错“remote: HTTP Basic: Access denied”解决方法

    问题: Git拉取项目时报错“remote: HTTP Basic: Access denied”,此问题多为本地密码与远端密码不符导致. 解决方法: 在下载地址中加上用户名和密码即可,如下: htt ...

  4. git拉取远程分支到本地

    git拉取远程分支到本地 一.查看远程分支 -- 查看远程分支 git branch -r 二.拉取远程分支并创建本地分支 -- 采用此种方法建立的本地分支会和远程分支建立映射关系. git chec ...

  5. git 拉取某个分支到本地

    git 拉取其实只需要 git fetch origin xxx. git pull origin xxx即可

  6. git拉取GitLab工程报错Repository not found

    # git clone http://xxx/jiqing/frog.git 正克隆到 'frog'... fatal: repository 'http://xxx/jiqing/frog.git/ ...

  7. git 拉取远程分支到本地并建立关联关系

    git拉取远程分支到本地   一.查看远程分支 使用如下git命令查看所有远程分支: git branch -r   二.拉取远程分支并创建本地分支 方法一 使用如下命令: git checkout ...

  8. 持续集成高级篇之Jenkins Pipeline git拉取

    系列目录 PipeLine中拉取远程git仓库 前面讲自由式任务的时候,我们可以看到通过自由式job里提供的图形界面配置git拉取非常方便的,实际上使用PipeLine也并不复杂.这一节我们展示一下如 ...

  9. vscode链接git拉取项目

    vscode终端中就可操作 初始化 git  init 链接 git git remote add origin http://**************.git 拉取项目 git clone ht ...

随机推荐

  1. 微信小程序——动态设置swiper的高度

    根据小程序的设定,swiper组件默认高度为150px,无法根据内容来撑高.如果里面的内容固定还好说,直接设置一个高度就可以了.要是里面内容是动态变化的,这个特性使得我们使用这个组件的时候感到诸多不便 ...

  2. CentOS7搭建以太坊私有链

    1. 环境准备:Win10 64位安装 VM VirtualBox,操作系统版本: CentOS-7-x86_64-Everything-1611.iso(7.71G). 切换root账号,方便安装程 ...

  3. webstrom IDE 激活

    2017.2.27更新 选择“license server” 输入:http://idea.imsxm.com/ 2016.2.2 版本的破解方式: 安装以后,打开软件会弹出一个对话框:选择“lice ...

  4. vue双向绑定的时候把遍历的数组转为了字符串,并且再转回去数组进行绑定

    我的问题大家可能不太懂,我详细再解释一下,就是我通过遍历一个大的数组,多层遍历之后,最后的值还是一个小的数组,形如: aaa:[ { bbb1:[ "111","&quo ...

  5. mysql可以远程连接的配置

    由于配置好几次了,老是会忘记命令,所以记录下来 1.修改配置文件 我的配置文件是/etc/mysql/mysql.conf.d/mysqld.cnf 找到 bind-address = 127.0.0 ...

  6. POI导出复杂的excel;excel公共样式类;excel拼接定制类;数据科学计数法转为普通值

    一.excel公共样式类(包含数据科学计数法转为普通值) package com.thinkgem.jeesite.common.utils.excel; import org.apache.poi. ...

  7. 【CF497E】Subsequences Return 矩阵乘法

    [CF497E]Subsequences Return 题意:设$s_k(x)$表示x在k进制下各位数的和mod k的值.给出k,现有序列$s_k(1),s_k(2),...s_k(n)$.求这个序列 ...

  8. Apache kylin的基础环境

    一.Apache kylin的基础环境 由于Apache kylin上的OLAP(wiki:OLAP)是构建在hadoop生态环境上的,所以hadoop环境的稳定性和健壮性对kylin的稳定运行至关重 ...

  9. Windows下安装配置Yaf框架的方法及创建典型合理的Demo目录结构

    Yaf是一个C语言编写的PHP框架,由鸟哥Laruence开发的高性能框架: Yaf官方文档:http://www.laruence.com/manual/index.html 第一步:安装PHP扩展 ...

  10. python爬虫工具

    一直都听说python写爬虫工具非常方便,为了获取数据,我也要写点爬虫,但是python太灵活了,不知道python爬虫要哪些框架,要了解,比如beatiful soup,scrapy, 爬虫的额主要 ...