1,下载及安装可参考如下百度经验:
https://jingyan.baidu/album/020278117cbe921bcc9ce51c.html?picindex=1
2,git初始化 项目用户名和邮箱:
git config --global user.name "username"
git config --global user.email "email"
3,获取公钥
出现如下错误时:
Warning: Permanently added the RSA host key for IP address '192.30.252.131' to the list of known hosts.
Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
是因为,没有在github账号添加SSH key
此时按时如下操作:
1)ssh-keygen -t rsa -C "....@..." //邮箱
2)输入保存路径(可使用括号提示中的路径,复制粘贴即可)
3) 输入私钥密码
4, git中使用命令将远程仓库拉取项目在本地文件夹
打开gitlab中的项目,点击右上角个人头像旁的倒三角,点击”settings",然后"SSH KEYS“,将第3点中生成的id_rsa.pub中的公钥复制进去,保存即可
5,第4步完成后,在git bash中输入
git clone ssh://git@......:22222/.........git
即可拉取gitlab中的项目
6,进入项目的目录中,即可进步git命令操作
7,修改remote方式
如果之前用的是https,那么需要将remote改为ssh;如果已经是ssh则不需要修改。
可以通过如下命令来查看当前的remote方式: git remote -v
如果当前是https的,那么可以通过如下命令修改为ssh: git remote set-url origin git@github:account/project.git
8,如果希望在git pull时不输入密码:
通过如下命令将密钥添加到ssh即可: ssh-add
注: 从openSSH 8.8版本开始,不再支持rsa加密生成的密钥
我们可以使用如下算法生成:
ssh-keygen -t ed25519 -C "15090552277@163"
更多推荐
windows下git客户端的下载安装及使用教程
发布评论