ssh 建立github验证

本文详细介绍如何通过生成SSH密钥实现无密码验证连接,并介绍了如何将密钥添加到远程仓库,如GitHub或GitLab。此外,还提供了使用Git进行项目初始化、提交和推送的基本步骤。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

建立ssh无验证连接
Check for SSH keys、
cd ~/.ssh
ls
Check the directory listing to see if you have a file named either id_rsa.pub or id_dsa.pub
检查有无产生过的key,一台机器只能创建一个。如果重新创建则前一个会被覆盖。
Generate a new SSH key
ssh-keygen -t rsa -C "your_email@example.com"# Creates a new ssh key, using the provided email as a label
这里的邮箱只是一个标识你可以随便取。对产生密钥没有影响。
增加密钥到远程仓库
~/.ssh/id_rsa.pub将这里的内容增加到远程ssh仓库中。


Download and Install Git
sudo apt-get install git


configure your settings
git config --global user.name "Your Name Here"# Sets the default name for git to use when you commit
git config --global user.email "your_email@example.com"# Sets the default email for git to use when you commit


创建一个仓库在github或者gitlab等网站上:
cd进入项目的根目录下
git init# Sets up the necessary Git files
git add .#adding it to the list of files to be committed
git commit -m 'first commit'# Commits your files, adding the message "first commit"


Push your commit
git remote add origin https://github.com/username/Hello-World.git# Creates a remote named "origin" pointing at your GitHub repository
git push origin master# Sends your commits in the "master" branch to GitHub


fork project#自己想帮助别人的项目,或想用别人的项目作为自己的起点。
先要ssh建立连接,见上面
然后git clone https://github.com/username/Spoon-Knife.git#不管是github还是gitlab都可以。git通用
Create branch with your feature
git checkout -b $feature_name
Write code. Commit changes
git commit -am "My feature is ready"
Push your branch to GitLab
git push origin $feature_name
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值