本地Git的基本配置和与GitHub(私有仓库)之间免登陆pull、push的方法

本地Git的基本配置和与GitHub(私有仓库)之间免登陆pull、push的方法

    • 1.设置本地用户名和邮箱
    • 2.生成秘钥
    • 3.对于已经拉完的工程
    • 4.直接重新clone仓库
    • 5.在执行git pull的时候,提示当前branch没有跟踪信息:
    • 参考文章:

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中。
本地Git的基本配置和与GitHub(私有仓库)之间免登陆pull、push的方法_第1张图片

3.对于已经拉完的工程

git remote rm origin #删除原有远程关联
git remote add origin https://username:[email protected]/your_repo_path.git  #设置新的关联依赖(注意将自己的账号密码添加到新的url中)

4.直接重新clone仓库

git clone https://username:[email protected]/your_repo_path.git

5.在执行git pull的时候,提示当前branch没有跟踪信息:

本地Git的基本配置和与GitHub(私有仓库)之间免登陆pull、push的方法_第2张图片
对于这种情况有两种解决办法,就比如说要操作master吧,一种是直接指定远程master:

git pull origin master

另外一种方法就是先指定本地master到远程的master,然后再去pull:

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

参考文章:

1.git 每次pull 私有仓库要求输入username 和 password 咋办?
2.Git: There is no tracking information for the current branch.

你可能感兴趣的:(Git)