git 如何设置提交用户名和密码_git提交的时候需要用户名和密码

帮一个C#的哥们从SVN转到了Git,算是好事一件了。通过keygen生成和配置了公钥,也配置到了remote端,安装好了sourceTree,checkout出代码就可以工作了。

昨天他说碰到一个问题,从命令行每次提交或者同步代码的时候都需要输入用户名和密码,感觉有点麻烦,让我帮忙看一看。我检查了.ssh/id_rsa.pub和远程配置的一样,通过ssh命令也可以和远程通讯,比如:

PTY allocation request failed on channel 0

Coding.net Tips : [Hello XXX! You've connected to Coding.net by SSH successfully! ]

Connection to coding.net closed.

那问题出在哪里呢?查看一下配置,git config -l如下:

ore.repositoryformatversion=0

core.filemode=true

core.bare=false

core.logallrefupdates=true

core.ignorecase=true

core.precomposeunicode=true

remote.origin.url=https://git.coding.net/XXX/storesystem.git

remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*

branch.master.remote=origin

branch.master.merge=refs/heads/master

看来clone的时候是使用的https,而不是ssh,所以配置的SSH是没有用得,需要改变一下remote.origin到SSH就可以了:

git remote remove origin

git remote add origin git@coding.net:XXX/storesystem.git

git branch --set-upstream-to=origin/master master

这样,就是使用SSH的方式了。使用git pull或者git push都可以不用输入用户名和密码了。比较了github和Coding,发现github提供了SSH和https的clone地址,而coding只提供了https的地址。这算不算是个问题呢?

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值