本地Git的基本配置和与GitHub之间免密pull、push的方法

本地Git的基本配置和与GitHub之间免密pull、push的方法
1.设置本地用户名和邮箱
git config --global user.name "your username(maybe not your git username)"
git config --global user.email "your email(maybe not your git email)"
2.设置公私密钥对
cd $HOME/.ssh
rm -f rsa*
ssh-keygen -t rsa -C "your email(step1)"

在生产公私钥对时一直按回车即可,将生成的rsa_pub公钥的内容复制一份到GitHub的SSH and GPG keys中

3.从远端clone项目代码到本地
git clone -b originbranch (master) httpaddres of your git-project(begin of https)
4.设置远端访问方式为ssh
git remote set-url origin sshaddres of your git-project(begin of git)
5.本地关联远程分支
git branch --set-upstream-to=origin/originbranch(master)
6.可设置git常用命令的别名:
alias gs='git status'
alias ga='git add'
alias gm='git commit -m'
alias gam='git commit -am'
alias gpul='git pull'
alias gpsh='git push'
注:.profile文件修改后,需要执行生效;windows下的aliases.sh修改后,重启gitbash即可。
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值