git提交到github笔记

原文参考:https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories
1、准备工作:
1.1 安装git
1.2 注册github
1.3 github新建一仓库,并查看两种提交的方式
-------------------------------------------- 方式一 ----------本地未做初始化的按照如下操作即可
echo "# dbhot" >> README.md
git init
git add README.md
git commit -m "first commit"
git branch -M main
git remote add origin git@github.com:jason/dbhot.git
git push -u origin main
-----------------------------------------------------本地已经初始化的按照如下操作即可
git remote add origin git@github.com:jason/dbhot.git
git branch -M main
git push -u origin main
-------------------------------------------- 方式二 ------------------------------------------

1.4 准备自己的账户信息 用户名、邮箱、密码

git config --global user.password "密码"
Jason
Jason@gmail.com

配置git 账户密码时bash:$:command not found
方案:
在配置git账户和用户名时:
$ git config --global user.name "名字"
$ git config --global user.email 邮箱

2、连接本地git到github需要密钥

一、检查ssh密钥
ls -al ~/.ssh

二、生成密钥 ***** 重点 ---> ssh-keygen -t ed25519 -C "yourEmail@example.com"
ssh-keygen -t ed25519 -C "我的邮箱"

注意: GitHub 通过在 2022 年 3 月 15 日删除旧的、不安全的密钥类型来提高安全性。
ssh-dss自该日期起,不再支持DSA 密钥 ( )。您不能将新的 DSA 密钥添加到您在 GitHub.com 上的个人帐户。

2021 年 11 月 2 日之前的RSA 密钥 ( ssh-rsa)valid_after可以继续使用任何签名算法。在该日期之后生成的 RSA
密钥必须使用 SHA-2 签名算法。一些较旧的客户端可能需要升级才能使用 SHA-2 签名。

三、向您的帐户添加新的 SSH 密钥

在OS系统中,复制文件内容到剪贴板(比如复制公钥到剪贴板)的命令是:
pbcopy < ~/.ssh/id_rsa.pub
pbcopy < ~/.ssh/id_ed25519.pub

在Win7或者Win10下这条命令就没用了。可以这样:
clip < ~/.ssh/id_rsa.pub
clip < ~/.ssh/id_ed25519.pub

四、复制github云端地址:HTTPS地址; SSH地址;
https://github.com/jason/dbhot.git
git@github.com:jason/dbhot.git

五、push两种方式:(HTTPS、SSH)
5.1 HTTPS
git remote add origin https://github.com/jason/dbhot.git
git branch -M main
git push -u origin main
5.2 SSH
git remote add origin git@github.com:jason/dbhot.git
git branch -M main
git push -u origin main

posted @ 2022-08-12 16:58  zechariah1  阅读(58)  评论(0编辑  收藏  举报