问题1:在terminal中使用git 指令push origin master提示需要输入用户名密码,如何不用每次输入?
答:1)配置git 的用户名和邮箱 (github账户注册的用户名和邮箱)
eg: git config --global user.name “kenventhunder”
git config --global user.email "[email protected]"
查看配置信息 git config --global --list
注意:当有多个网站的使用的时候,比如同时使用码云和github要注意每次使用的更改
2)生成ssh 公钥和私钥,公钥私钥用于非对称加密,公钥放置于github网站,私钥放置于本机存储
输入命令 ssh-keygen -t rsa -C "[email protected]"
enter后结果如下
Generating public/private rsa key pair.
Enter file in which to save the key (/Users/zss/.ssh/id_rsa): 注意这个地方直接点enter即可,否则输入特定文件名比如githubrsa
默认生成的两个文件 githubras githubras.pub在当前目录下,注意生成的私钥公钥必须放在/Users/zss/.ssh/ 这个目录下(当然zss指的是具体mac用户名),否则git后续指令会提示权限不对
如果接下来提示
/Users/zss/.ssh/id_rsa already exists.
Overwrite (y/n)? 选择y覆盖即可。
3)vim /Users/zss/.ssh/id_ras.pub 拷贝其中的内容到github相应的项目仓库 Settings -> Deploy keys -> Add deploy key,注意勾选下面的write权限
4)然后拷贝项目路径到本地clone即可,注意路径使用 ssh形式的eg: [email protected]:kevinthunder/test.git,不要使用https的。
问题2:项目从github下拉(clone)到了本地,执行命令后报错
问题3:执行push origin master 报错
fatal: 'orign' does not appear to be a git repository
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
可能原因分析:指令错了,比如 pull origin master 输入成了 pull orign master
Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
上述问题1中2)生成的私钥公钥未放在/Users/your user name/.ssh/ 这个目录下