本地git提交到远程仓库

1、设置全局变量name、email

git config --global user.name "Your Name"
git config --global user.email "email@example.com"

2、生成公钥

ssh-keygen -t rsa -C "94*****@qq.com"

3、在github设置页选择SSH and GPG keys

选择New SSH key,填写title,复制上一步生成的公钥id_rsa.pub全部内容到Key输入框中,然后点击Add SSH key,输入密码完成认证。

4、复制github工程地址

git clone https://github.com/***.git

5、修改内容之后

git add .
# 随意写点注释吧
git commit -m "***"
git push

之后会弹框输入用户名密码,就可以了。

6、不输入用户名密码提交远程仓库

因为之前复制的地址是https,而不是ssh,打开.git文件夹中的config文件

[core]
	repositoryformatversion = 0
	filemode = false
	bare = false
	logallrefupdates = true
	symlinks = false
	ignorecase = true
[remote "origin"]
	url = https://github.com/***.git
	fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
	remote = origin
	merge = refs/heads/master
[gui]
	wmstate = normal
	geometry = 841x483+25+25 189 218

修改url为:git@github.com:***.git,这个链接可以在github网站上复制

再重新git push

$ git push
The authenticity of host 'github.com (13.229.188.59)' can't be established.
RSA key fingerprint is SHA256:nThbg6kXUpJWGl7E1IGOCspRomTxdCARLviKw6E5SY8.
Are you sure you want to continue connecting (yes/no)? y
Please type 'yes' or 'no': yes
Warning: Permanently added 'github.com,13.229.188.59' (RSA) to the list of known hosts.
Enumerating objects: 6, done.
Counting objects: 100% (6/6), done.
Delta compression using up to 4 threads
Compressing objects: 100% (4/4), done.
Writing objects: 100% (4/4), 40.29 KiB | 138.00 KiB/s, done.
Total 4 (delta 2), reused 0 (delta 0)
remote: Resolving deltas: 100% (2/2), completed with 2 local objects.
To github.com:poene/poene.github.io.git
   b531db6..b2bbef5  master -> master

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值