777 Star 1.5K Fork 353

开源中国 / Gitee Feedback

 / 详情

HTTPS 方式接入码云保存密码的方式

结束任务
Task member
Opened this issue  
2014-04-03 21:35

https 方式每次都要输入密码,按照如下设置即可输入一次就不用再手输入密码的困扰而且又享受 https 带来的极速

设置记住密码(默认15分钟):

git config --global credential.helper cache

如果想自己设置时间,可以这样做:

git config credential.helper 'cache --timeout=3600'

这样就设置一个小时之后失效

长期存储密码:

git config --global credential.helper store

增加远程地址的时候带上密码也是可以的。(推荐)

http://yourname:password@gitee.com/name/project.git

补充:使用客户端也可以存储密码的。

如果你正在使用ssh而且想体验https带来的高速,那么你可以这样做:
切换到项目目录下 :

cd projectfile/

移除远程ssh方式的仓库地址

git remote rm origin

增加https远程仓库地址

git remote add origin http://yourname:password@gitee.com/name/project.git

Update:

Git-for-Windows 默认带有 Git-Credential-Manager-for-Windows

Linux 和 Mac 用户可以使用: Git-Credential-Manager-for-Mac-and-Linux

安装文档:
https://github.com/Microsoft/Git-Credential-Manager-for-Mac-and-Linux/blob/master/Install.md

搞定,enjoy the speed!

Comments (88)

难怪,谢谢提醒

我刚才用ssh方式:git pull
ssh_exchange_identification: Connection closed by remote host
fatal: The remote end hung up unexpectedly

ssh拉小更新其实还是快一点,不用输密码

确实,好几天了,太慢了,我还以为oschina要挂了 :)

TortoiseGit在自己的用户目录下(%USERPROFILE%)新建_netrc增加

machine git.oschina.net

login username

password password

这样你所有仓库匹配到git.oschina.net都会自动使用该账户密码

多谢分享。

为啥我 git config --global credential.helper cache之后,每次push还是需要输入用户名和密码??

你可能没设置好,我这边是没有问题的

git config --global credential.helper store 试试这个

然后看看你的.gitconfig文件有没有

[credential]

    helper = store

提示各位windows用户,可以下载git-credential-winstore,http://gitcredentialstore.codeplex.com/

下载直接安装即可。 git config --global credential.helper store方式没有测试,因为已经通过安装git-credential-winstore了。希望楼下有人验证一下。

替换remote方式

查看当前remote: git remote -v

更新remote:

git remote set-url origin https://git.oschina.net/username/YourRepo

git config --global credential.helper store我的mac测试通过。

git config --global credential.helper store
win7下 测试OK

git config --global credential.helper store
这样会把账号密码明文存储到 ~/.git-credentials中

嗯,是的,永久保存嘛

按上面的来,别输错了

原来http可以永久保存密码的,那我也不用ssh了

这几天使用下来https也不是很快,是问题也对https有影响?

小白一个,刚刚学会SSH,又改成http了 我遇到这个 提示 , 求大神支招啊:)
fatal: could not read Username for 'http://git.oschina.net': No such file or directory...

http换成https

fatal: could not read Username for 'https://git.oschina.net': No such file or directory 不是吧、同样出问题

AAA
我用了最无脑的方法,哎..

eclipse能不能用https保存密码啊,求解

默认的credential.helper store会把密码以明文的方式存在与.gitconfig同目录下的.git-credentials文件中。git-credential-winstore利用Windows自带的凭证管理系统来存放密码,感觉会更安全一些。不过感觉速度好像会慢一些(也许是我的错觉)。

在我影像中因为 ssh 方式支持压缩,而https方式不支持压缩,所以ssh 方式应该速度上优于https的啊
为啥到了这里却是 https 速度快了

强烈推荐SourceTree :smile:


支持Gitflow哦~ :+1:

git push

error: The requested URL returned error: 401 Unauthorized while accessing https://git.oschina.net/konakona/********.git/info/refs

fatal: HTTP request failed

HTTPS方式是不是有最大上传限制?我不记得具体多少了,好像是25MB?公司有防火墙不让SSH方式过,只能用HTTPS,然后有一次我push了很久没push的一个C#.NET项目,然后就告诉我上传失败。Google后得知是上传量太大超过HTTPS方式限制。这个怎么解决?

用http不可以吗? 我感觉速度还行阿。

最后两步可以整合成一句:

 git config remote.origin.url https://git.oschina.net/username/project.git	

我是来测试下图片的:)

图片有点大,影响本文得阅读,已经删除,望谅解。

git push origin master
error: The requested URL returned error: 401 Unauthorized while accessing https://git.oschina.net/shine_forever/pyTest.git/info/refs

fatal: HTTP request failed

这个怎么解决啊!?

git remote -v 发出来看一下

不知道为什么,明明是https,后台总有的项目创建是http,有的是http是的!以前用都没问题,就是最近push都不成功!?

fatal: http://git.oschina.net/shine_forever/pyTest.git/info/refs/info/refs not found: did you run git update-server-info on the server?

fatal: http://git.oschina.net/shine_forever/pyTest.git/info/refs/info/refs not found: did you run git update-server-info on the server?

全局不好使,我在项目下的./git/config文件里进行了设置后可以免登陆,希望对大家有用
OS:windows7 x64

为什么推荐使用HTTPS,不是SSH会更快吗?

两者都是差不多得,只不过ssh有时候可能服务不稳定,所以推荐https,最近ssh还是比较稳定得。

用户名或者密码含有@符号的何如拼接成 http://yourname:password@git.oschina.net/name/project.git 的形式

用户名或者密码含有@符号的何如拼接成 http://yourname:password@git.oschina.net/name/project.git 的形式

@ 替换成 %40 试试

undefined
提交和拉去都要重新输入密码,这个怎么破?
git版本
undefined
win7_64位

远程地址换成带用户名和密码的。

D3952036-5983-40B3-A1A2-633A556B1E39
有人解决了这个问题了嘛?

.git/config 修改为:

D12EAD96-B74E-4FB7-B7E7-F0ED80D1F8A0

如何取消关注,每次都收到邮件,很繁琐,谢谢!

您好,在个人信息里面的通知修改。

@郑健 貌似在那个关了,和自己项目有关的通知也不会通过邮件发送了,能不能值通知和自己项目有关的和自己订阅的?

您的意思是不想关注git@osc这个对吧,那就在项目的右上角有个unwatch

@郑健 谢谢,不知何时watch了git@osc

@郑健 请问 我那个问题,有解决方案嘛?

@八面 增加远程地址的时候带上密码也是可以的。(推荐)

http://yourname:password@git.oschina.net/name/project.git

@郑健 你说的方式: http://yourname:password@git.oschina.net/name/project.git 我也有测试,依然是无法push

是我使用错误 还是git@osc的bug?急~~

多谢

以下是使用: 增加远程地址的时候带上密码 方式来git push的结果

22

23

这个肯定是密码的问题,你可以尝试重新修改下密码。

@郑健 尽管我已经unwatch,但是还是能收到

@leohxj 我在xp系统下,在dos界面使用git

试了 credential.helper winstore ,提示命令找不到

改用 credential.helper wincred ,生效

感这两个命令有什么区别吗?

@郑健 不好意思,第一个应该是winstore,当时没注意发错了,已更正,感谢提醒。

@shouldsimple 嘿嘿,我说呢,我一个字母一个字母的还对比了一下 - -. 感谢共享,Git@OSC有你更精彩!

大神!给跪!

谢谢。有用呢。

被坑了下,我在debian下测试ok的命令如下:
长期存储密码:
git config --global credential.helper store
移除远程ssh方式的仓库地址
git remote rm origin
增加https远程仓库地址
git remote add origin https://yourname:password@git.oschina.net/yourname/yourprojectname.git
or git remote add origin http://yourname:password@git.oschina.net/yourname/yourprojectname.git
示例 yourname:debian,password:123456创建的cinterview项目
git remote add origin https://debian:debian@git.oschina.net/debian/cinterview.git

最后两步可以整合成一句:
git config remote.origin.url https://git.oschina.net/username/yourprojectname.git
示例 yourname:debian,password:123456创建的cinterview项目
git config remote.origin.url https://git.oschina.net/debian/cinterview.git

几种方式都可以的。

Status changed to closed

Zoker approved 任务
liu assigned 任务to Zoker
liu added label discussion
liu added label support
liu removed label discussion
liu removed label support

干嘛不生成ssh key?

@lichenyi-os-git 有不想用sshkey

@Zoker 使用sshkey是有什么弊端吗

@lichenyi-os-git 有人干设置设置不好

江二十三 updated 任务
江二十三 updated 任务

原来私有项目必须要带 用户名和密码才有更新,但是如果在终端直接去pull或者push就不需要。 因为之前已经配置过了全局的账户密码,但是使用PHP exec 去直接Git pull的时候还是一直提示 fatal: could not read Username for 'https://gitee.com': Device not conf,邮箱的@替换成 %40就OK了,看了这篇文章就解决了 :smile:

git remote add origin http://yourname:password@gitee.com/name/project.git
这个方法,貌似password里面有!@#¥%等特殊字符会不成功。。。

Zoker changed top level from Low to Not top

@Shaco_Ma 要转义,比如要把@变成%40

@Zoker

git config --global credential.helper cache

请问这个命令是在远程仓库设置的么?
我本地仓库不设置的话,发现现在码云的https也是只有第一次需要输入密码

诺墨 Issue migrate from 任务 to Task
Zoker changed issue type from 任务 to Task
Zoker changed issue state from 已验收 to 结束任务

Sign in to comment

Status
Assignees
Projects
Pull Requests
Successfully merging a pull request will close this issue.
Branches
Planed to start   -   Planed to end
-
Top level
Priority
Duration (hours)
参与者(45)
5071 martin 1578914306 62561 kesin 1578916009 1281 for 1988 1578913984 7518 wpjsolo 1578914491 12983 moli 1578914878 19022 wl 1578915236 83908 moshi 1578916805 5029 ryfthink 1578914302
加载更多
Ruby
1
https://gitee.com/oschina/git-osc.git
git@gitee.com:oschina/git-osc.git
oschina
git-osc
Gitee Feedback

Search