Linux使用git连接github

从GitHub上克隆项目到本地并提交修改

新建一个目录用于存放github仓库

cd /var/opt && sudo mkdir github && sudo chmod 777 github

获取个人永久Token

# 参考https://www.cnblogs.com/oldweipro/p/16612197.html
1.点击 settings
2.点击右侧的 Developer settings
3.点击 Personal access tokens(个人访问令牌)
4.点击 Generate new token
5.设置 token 信息
6.根据所需过期时间,建议设置成永远,以免麻烦,建议所有选项都选上
7.点击 Generate token 生成令牌
8.得到生成的令牌
9.应用令牌
10.修改现有的 url
git remote set-url origin  https://<your_token>@github.com/<USERNAME>/<REPO>.git
将<your_token>换成你自己得到的令牌。<USERNAME>是你自己github的用户名,<REPO>是你的项目名称

修改代码

cd /var/opt/github
# 注意克隆的时候直接在仓库根目录即可, 不用再创建项目根目录
git clone https://github.com/GitHubYuanHao/NodeJSExtensions.git
# 修改代码
# 将目录中所有文件添加
git add ./*
#提交缓存
git commit -m '提交'
#提交缓存
git push
# 遇到错误 gnutls_handshake() failed: Error in the pull function
# 按照https://zhuanlan.zhihu.com/p/638407228似乎要编译git
# 我在ubuntu20.04上运行export GIT_CURL_VERBOSE=1就提交成功了
posted @ 2023-10-21 00:17  Linux袁浩  阅读(53)  评论(0)    收藏  举报