美文网首页
git账户问题

git账户问题

作者: 米酒真香 | 来源:发表于2018-07-16 16:11 被阅读24次

我把写的爬虫放到github码云上面
本地项目同时关联这2个仓库
进入本地项目的文件夹
git init 初始化项目
git add . 把文件放到暂存区
git commit -m "提交信息"

git remote add github https://github.com/wtgg/my_spiders # 关联github上面的仓库
git remote add gitee https://gitee.com/wtgg/my_spiders  # 关联码云上面的仓库

此时,github上的仓库在本地的名字为github,而不是origin
同样,码云上的仓库在本地的名字是gitee,而非origin
git remote -v查看远程库信息,可以看到两个远程库:

gitee   https://gitee.com/wtgg/my_spiders.git (fetch)
gitee   https://gitee.com/wtgg/my_spiders.git (push)
github  https://github.com/wtgg/my_spiders.git (fetch)
github  https://github.com/wtgg/my_spiders.git (push)

如果要推送到GitHub,使用命令:
git push github master
如果要推送到码云,使用命令:
git push gitee master
这样一来,我们的本地库就可以同时与多个远程库互相同步。
全局的用户名密码配置:

$ git config --global user.name "xxxxx"
$ git config --global user.email "xxxxx"

设置长期记住密码:
git config --global credential.helper store
用户名和密码存贮的位置是:
C:\Users\用户名\.gitconfig 文件

分项目的用户名密码配置:
对应的本地仓库的.git文件夹中的config文件

git push 之后会在
C:\Users\用户名\.git-credentials 文件中添加对应的仓库和密码
之后再推送就不用再输密码了

hexo网站代码仓库说明

参考1:廖雪峰的官方网站
参考2:码云(Gitee.com)帮助文档

相关文章

网友评论

      本文标题:git账户问题

      本文链接:https://www.haomeiwen.com/subject/myjbpftx.html