git 建立本地仓库并且推送到github上

引言

我想讲我的笔记备份一份保存到github上去,所以我使用git来完成这个目标。

下载Git

首先下载git,由于我是mac,所以我使用了homebrew,直接使用homebrew 下载。

bash 复制代码
brew install git

创建仓库并本地推送

下载完成之后,我在自己笔记文件的位置建立一个本地仓库

csharp 复制代码
cd /笔记文件夹
git init 

# 配置名字 和 邮箱
git config --global user.name "待输入"
git config --global user.email "待输入"

# 查看配置
git config --global --list

将我的整个文件夹都添加到我的仓库,并提交

sql 复制代码
git add .
git commit -m "待输入【输入提交的explain】"

拿到git密钥

使用 git 生成 密钥

bash 复制代码
# 这里是通过 ed25519 这么一种加密算法来生成 ssh 密钥的一种算法, 后  面"[email protected]" 是一种身份标识,为密钥添加注释
ssh-keygen -t ed25519 -C ssh-keygen -t ed25519 -C 
# 展示密钥
cat ~/.ssh/id_ed25519.pub

添加密钥

然后进入 github网站

在 ssh and GPG keys 中间去添加新的密钥

将刚刚拿到的密钥添加

测试:

perl 复制代码
ssh -T [email protected]
# 将会返回 Hi **! You've successfully authenticated, but GitHub does not provide shell access.

推送

推送:

css 复制代码
git branch
# 返回的是 * main

# 推送这个main
git push -u origin main

完成了将这个笔记上传到了我的github上了

相关推荐
Jditinpc3 小时前
Git使用
git
貂蝉空大4 小时前
Git 常用命令大全
git
兔斯基灬木木7 小时前
【技术工具】源码管理 - GIT工具
git
工呈士9 小时前
Git 工作流与版本管理策略
前端·git·面试
C++ 老炮儿的技术栈9 小时前
文本文件与二进制文件的区别
大数据·c语言·开发语言·c++·git·算法·visual studio
Jooolin13 小时前
【编程史】Gitee是啥?它和GitHub关系是什么?
git·github·ai编程
貂蝉空大14 小时前
Git Switch 与 Git Restore 详解
git
aini_lovee1 天前
python在容器内克隆拉取git私有仓库
git·python·elasticsearch
zhangphil1 天前
git merge合并分支push报错:Your branch is ahead of ‘xxx‘ by xx commits.
git
2018_XWJ1 天前
本地项目push到git
git