云南省人防工程建设网站,电子商务网站建设实验报告心得,soho的外贸网站,建设网站有什么作用git多账号切换其实是有https的解决方案的#xff0c;可以省去ssh配置公钥相关的麻烦#xff0c;不过安全性会降低#xff0c;后面会提到。比如你想用A账号管理本地仓库repoA#xff0c;用B账号管理本地仓库repoB。那么首先#xff0c;看一下gloabal和system的config#…git多账号切换其实是有https的解决方案的可以省去ssh配置公钥相关的麻烦不过安全性会降低后面会提到。比如你想用A账号管理本地仓库repoA用B账号管理本地仓库repoB。那么首先看一下gloabal和system的configgit config --global -lgit config --system -l主要是看有没有credential.helper把账号密码存起来了。因为https的url方式每次push的时候都要输入密码比较麻烦一般就会用credential.helper把账号密码存在global里了。这样对单用户没问题但多用户时就会有问题。如果存的是A账户那在repoB里push的时候肯定就会permission denied。所以看看global或者system哪个设置了保存就unset一下git config --global --unset credential.helpergit config --system --unset credential.helper第二个命令可能需要权限吧。接下来就是对本地仓库的config设置了。比如进入本地仓库repoA之后看一下urlgit remote -vhttps开头的就是用的https了git 开头的就是用的ssh了一般用浏览器打开github仓库页面之后在页面里copy的都是https。一般是长这个样子然后在https://和http://github.com之间加上用户名 用set-url设置就好git remote set-url origin https://UserAgithub.com/UserA/repoA.git当然默认是origin分支要设置其他分支也一样。 前的用户名和仓库权限的拥有者要对应起来。改好之后这时候push就要输入一下用户A的密码然后就能push上去了。对于repoB也是一样。每次push都需要输入密码了。那么为了避免麻烦针对每一个本地仓库设置一下local的credential.helpergit config --local credential.helper store这样账号密码就只针对当前仓库保存对其他仓库没有影响了。针对每一个需要管理的本地仓库都需要按以上步骤设置一次url和credential.helper设置好之后就能一直正常push了。总结一下1. 清空global和system的credential.helper2. 对每一个本地仓库设置一下url和local的credential.helper关于安全性的问题用git credentials存凭证的话密码是以明文形式存储的不论是git-credentialsstore还是git-credentialswinstore(windows)git-credentialsosxkeychain(Mac)都有办法直接看到密码明文除非用git-credentialscache。当然也可以自定义参考7.14 Git 工具 - 凭证存储。