使用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,大功告成

相关推荐
逛逛GitHub4 分钟前
推荐 5 个 yyds 的 Claude Skills 开源项目。
github
y***548838 分钟前
Git在开源项目中的协作
git
weixin_436525071 小时前
使用 idea 命令行构建 Docker 镜像并部署到云服务器
linux·docker·github
MicrosoftReactor5 小时前
技术速递|GitHub Copilot CLI:快速上手指南
github·copilot
老友記5 小时前
git cherry-pick使用
git
蜜汁小强6 小时前
Github 账号与登录 2025
github
练习时长一年6 小时前
git常用命令总结
大数据·git·elasticsearch
Sahadev_7 小时前
GitHub 一周热门项目速览
github
CoderJia程序员甲7 小时前
GitHub 热榜项目 - 日榜(2025-11-24)
ai·开源·llm·github·ai教程
hadage2338 小时前
--- git 的一些使用 ---
开发语言·git·python