GitHub上传文件
SSH keys配置
操作流程
-
首先用在Git Bash上输入
~/.ssh
如果电脑上有,就会显示bash: /c/Users/…/.ssh: Is a directory
如果电脑上没有,那就显示bash: /c/Users/…/.ssh: No such file or directory -
第1步如果是没有,则在Git Bash中输入
ssh-keygen -t rsa -C "邮箱"
然后就会显示这两行:
Generating public/private rsa key pair.
Enter file in which to save the key (/c/Users/16627/.ssh/id_rsa):
这里让你输入一个文件名,建议直接回车。后面会让你输入密码,在上传文件的时候会问你的密码。 -
添加SSH Key到GitHub
. 首先打开Github网页,右上角头像处左键Setting,SSH and GPG keys。
Title随便设置,Key则是第1步中.ssh
文件夹中id_rsa.pub
文件,复制粘贴上去即可。添加之后会有邮件提醒。 -
测试一下该SSH key
在git Bash 中输入以下代码
ssh -T git@github.com
然后会提示你:
The authenticity of host ‘github.com (13.229.188.59)’ can’t be established.
RSA key fingerprint is SHA256:nThbg6kXUp…
Are you sure you want to continue connecting (yes/no/[fingerprint])?
输入yes,回车
接下来就会提示你输入密码,如果上边设置ssh的时候,你没设置密码会提示你:
Warning: Permanently added ‘github.com,192.30.255.112’ (RSA) to the list of known hosts.
警告完了,如果你能看到如下提示,那你已经成功设置SSH密钥。
Hi “用户名”! You’ve successfully authenticated, but GitHub does not provide shell access.
如果你看到 access denied,者表示拒绝访问,那么你就需要使用 https 去访问。
参考
https://blog.csdn.net/qq_36667170/article/details/79094257
GitHub上传
上传文件
README.md
git init
git add README.md
git commit -m “first commit”
git branch -M main
git remote add origin git@github.com:#/##.git
git push -u origin main
上传文件夹
git init
git add *
git commit -m “first commit”
git remote add origin git@github.com:#/##.git
git push -u origin master
上传R包
git init
git add README.md
git add *
git commit -m “first commit”
git branch -M main
git remote add origin git@github.com:#/##.git
git push -u origin main
git init
git add *
git commit -m “first commit”
git remote add origin git@github.com:#/##.git
git push -u origin master
git init
git branch -M main
git remote add origin git@github.com:#/##.git
git branch -M main
git push -u origin main
注:#代表GitHub名,##代表仓名。