本地git提交到远程仓库

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_33440246/article/details/84455308

1、设置全局变量name、email

git config --global user.name "Your Name"
git config --global user.email "[email protected]"

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为:[email protected]:***.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

猜你喜欢

转载自blog.csdn.net/qq_33440246/article/details/84455308