Git配置文件,GitHub与码云免密登陆

3 篇文章 0 订阅
1 篇文章 0 订阅

配置文件存放三个位置

项目配置文件:项目/.git/config

git config --local user.name ‘xxx’
git config --local user.email ‘xxx@xx.com’

全局配置文件:~/.gitconfig

git config --global user.name ‘xxx’
git config --global user.name 'xxx@xx.com

系统配置文件:/etc/.gitconfig

git config --system user.name ‘xxx’
git config --system user.name ‘xxx@xx.com’
注意:需要有root权限

免密码登录

GitHub

URL中体现

原来的地址:https://github.com/xxx/dbhot.git
修改的地址:https://用户名:密码@github.com/xxx/dbhot.git
git remote add origin https://用户名:密码@github.com/xxx/dbhot.git
git push origin master

SSH实现
1.生成公钥和私钥(默认放在~/.ssh目录下,id_rsa.pub公钥、id_rsa私钥) ssh-keygen
2.拷贝公钥的内容,并设置到github中。 
3.在git本地中配置ssh地址
git remote add origin git@github.com:juran/dbhot.git
4.以后使用
git push origin master
git忽略文件

让Git不再管理当前目录下的某些文件。

*.h    
!a.h  
files/  
*.py[c|a|d]

码云

码云创建ssh公钥
ssh-keygen -t rsa -C “xxxxx@xxxxx.com” # 将邮箱替换成码云注册邮箱。
回车三次即可生成sshkey

在这里插入图片描述
查看 public key,并把他添加到码云(Gitee.com) cat ~/.ssh/id_rsa.pub # 将ssh-rsa到邮箱部分的内容复制出来
在这里插入图片描述
添加用户sshkey
通过个人》设置,添加ssh公钥

在这里插入图片描述
在这里插入图片描述

在terminal中继续执行
ssh -T git@git.oschina.net

返回Welcome to Git@OSC, yourname!表示添加成功。
变更为ssh协议认证

将https协议认证变成ssh协议认证
git remote rm origin # 将远程的提交方式删除,然后添加新的提交方式 git remote add origin git@github.com:xxx/xxx.git

更多参考:https://github.com/github/gitignore

github任务管理相关

  • issues,文档以及任务管理。
  • wiki,项目文档。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值