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 密钥的一种算法, 后  面"yakcalire@outlook.com" 是一种身份标识,为密钥添加注释
ssh-keygen -t ed25519 -C ssh-keygen -t ed25519 -C 
# 展示密钥
cat ~/.ssh/id_ed25519.pub

添加密钥

然后进入 github网站

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

将刚刚拿到的密钥添加

测试:

perl 复制代码
ssh -T git@github.com
# 将会返回 Hi **! You've successfully authenticated, but GitHub does not provide shell access.

推送

推送:

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

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

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

相关推荐
jiayong238 小时前
Git 核心概念:Tag 与 Branch 的本质区别
git
Serene_Dream11 小时前
git 合并冲突的分支
git
我是一只puppy12 小时前
使用AI进行代码审查
javascript·人工智能·git·安全·源代码管理
玄同76513 小时前
Git常用命令指南
大数据·git·elasticsearch·gitee·github·团队开发·远程工作
十步杀一人_千里不留行16 小时前
Git提交前ESLint校验实践(Husky + lint-staged)
git·github
hh随便起个名19 小时前
适合小白的git的基础使用方法
git
我会一直在的19 小时前
Devps持续集成
git·ci/cd
CoderJia程序员甲20 小时前
GitHub 热榜项目 - 日榜(2026-02-08)
git·ai·开源·llm·github
Serene_Dream21 小时前
git 常用命令
git
jiayong231 天前
Detached HEAD 状态详解
git