栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 系统运维 > 运维 > Linux

在Ubuntu使用Git访问Github

Linux 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

在Ubuntu使用Git访问Github

参考博客:如何在ubuntu下使用Github?_tina_ttl的博客-CSDN博客_ubuntu访问github参考1廖雪峰github教程安装Gitsudo apt-get install git git-core git-gui git-doc git-svn git-cvs gitweb gitk git-email git-daemon-run git-el git-arch配置Github(1)注册GitHub,创建版本库(2)检查SSH因为GitHub会用到SSH,因此需要在shell里检https://blog.csdn.net/tina_ttl/article/details/51326684

1. 安装Git
sudo apt-get install git
2. 创建私钥和公钥

提示:已有私钥和公钥可跳过此节

输入

cd ~/.ssh   #进入ssh目录
ssh-keygen -t rsa -C "email" #email为你的邮箱

示例

3. GitHub设置公钥
gedit ~/.ssh/id_rsa.pub  # 打开公钥文件

复制里面的内容后,在GitHub中,点击右上角头像,依次点击Settings -> SSH and GPG keys -> New SSH Key,将复制的内容粘贴进去。

输入

ssh -T git@github.com

出现以下内容,表示添加成功:

Hi xxx! You’ve successfully authenticated, but GitHub does not provide shell access.

4. 配置Git
git config --global user.name 你的github用户名
git config --global user.email 你的github邮箱地址

示例

5. 其他操作 5.1 初始化git
git init
5.2 克隆项目
git clone https://github.com/github用户名/github仓库名.git 
5.3 添加文件xxx至git缓存
git add xxx
5.4 设置commit内容为'xxx'
git commit -m 'xxx'
5.5 与仓库建立连接
git remote add origin https://github.com/github用户名/github仓库.git  

这里会要求输入Github账号和密码

由于github更新了规则,如果输入登录密码会出现报错

remote: Support for password authentication was removed on August 13, 2021

参考博客remote: Support for password authentication was removed on August 13, 2021_IT博客技术分享的博客-CSDN博客https://blog.csdn.net/qq_41646249/article/details/119777084进入github网站,点击右上角头像,依次点击settings -> Developer settings -> Personal access tokens

设置一个token,给他开通相关的权限并设置使用期限,并记录该token到一个记事本中,因为以后都要用到这个token进行登录。

最后,与仓库建立连接所需的密码均需使用该token

5.6 提交更改到主分支

github在2020.10.01宣布上的所有新库都将用中性词main命名,取代原来的master

所以这里也用main替换master,如果原先为master则不必替换

git push origin main

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/851401.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号