使用Git管理github的代码库-上

1、下载安装Git

https://download.csdn.net/download/notfindjob/11451730?spm=1001.2014.3001.5503

2、注册一个github的账号(已经注册的,可略过这一步)

3、打开git命令行,配置github账号

|-----------------------------------------------|
| git config --global user.name "你的用户名" |

|-------------------------------------------------------|
| git config --global user.email "你的github注册邮箱" |

4、在github上建立一个新的代码库,在git命令行输入命令克隆代码库到本地(默认克隆到本地"""C:\Users\Administrator")

|--------------------------------------------------------|
| git clone https://github.com/你的用户名/你的代码库名称.git |

5、使用Git GUI打开刚才克隆的本地代码库

6、在此代码库中添加文件,commit、push,会提示输入账号和密码

7、问题处理:

因为2021年8月13日之后,已经不支持https提交代码,故需要设置ssh方式

1)找到刚才克隆的本地代码库,在.git里边找到config文件。

2)修改config文件,将https修改为ssh方式,ssh后边的字段可以到github上复制

3) git配置账号、密码(第3步已经完成,可以略过),同步骤3

4)生成ssh证书

|-------------------------------------------|
| $ ssh-keygen -t ed25519 -C "你的邮箱" |

5)下载并开启ssh代理服务器

https://download.csdn.net/download/notfindjob/89302323

错误处理:Could not open a connection to your authentication agent

a、说明是代理没有开启或者开启参数不对

|----------------------------------|
| $ eval "$(ssh-agent -s)" |

|-------------------------------|
| ssh-add ~/.ssh/id_rsa |

6)github中设置SSH密钥

Git配置SSH Key的时候提示密钥无效操作步骤

a、生成公钥

ssh-keygen -t rsa -C "GitHub邮箱"

b、进入路径

vim ~/.ssh/id_rsa.pub

c、复制公钥到GitHub设置SSH and GPG keys中的SSH keys

d、解决方法:

第b步使用如下命令后复制

cat ~/.ssh/id_rsa.pub

8、重新push,大功告成

相关推荐
REDcker1 小时前
Git分支可视化管理面板设计与选型
git
Chan161 小时前
MCP 开发实战:Git 信息查询 MCP 服务开发
java·开发语言·spring boot·git·spring·java-ee·intellij-idea
yanlaifan2 小时前
恢复git硬删除的commit
git
阿琳a_3 小时前
在github上部署个人的vitepress文档网站
前端·vue.js·github·网站搭建·cesium
学渣y5 小时前
git分布式版本控制系统
分布式·git·elasticsearch
wuxuand6 小时前
GitHub页面配置
github
darkb1rd6 小时前
claurst:Rust 重构终端编码代理实战指南
开源·github·好物分享
时空无限6 小时前
git 文件冲突之后如何操作
git
小雨青年6 小时前
当缓存成为生产力:GitHub Actions 缓存机制的深度优化指南
缓存·github