Linux运维工具-ywtool
目录
- 一.访问github
- 二.新建仓库
- [三.通过git bash软件上传文件](#三.通过git bash软件上传文件)
-
- 1.提示
- [2.打开git bash软件](#2.打开git bash软件)
- 3.切换到本地仓库目录
- 4.配置github的用户名和邮箱信息
- [5.生成SSH Key](#5.生成SSH Key)
- [6.github添加新的ssh key](#6.github添加新的ssh key)
-
- [6.1 点击头像](#6.1 点击头像)
- [6.2 点击"Settings"](#6.2 点击"Settings")
- [6.3 点击"New SSH key"](#6.3 点击"New SSH key")
- 7.拷贝公钥
- 8.初始化仓库
- 9.切换为main分支(可选)
- 10.添加至git仓库缓存区
- 11.将暂存区中的内容提交到本地仓库中
- 12.将远程仓库添加到本地
- 13.将本地文件的推送到远程仓库的main分支上
- 四.刷新github页面
一.访问github
二.新建仓库
1.点击自己头像

2.选择"your repositories"

3.点击"New"

4.创建新仓库

三.通过git bash软件上传文件
1.提示
新建完仓库后,如果没有添加README.md文件,会有提示教怎么上传
2.打开git bash软件
3.切换到本地仓库目录
提前在自己电脑的磁盘上新建一个文件夹,专门用来上传github的文件
bash
cd /path/to/your/local/repo
4.配置github的用户名和邮箱信息
bash
git config --global user.name "username"
git config --global user.email "email"
5.生成SSH Key
添加自己的邮箱地址
下面这条命令会在"C:\User\用户名"目录下生成.ssh目录,里面有两个文件"id_rsa"(私钥)、"id_rsa.pub"(公钥)
bash
ssh-keygen -t rsa -C "xxx@qq.com"
6.github添加新的ssh key
6.1 点击头像

6.2 点击"Settings"

6.3 点击"New SSH key"

7.拷贝公钥
将"C:\User\用户名\id_rsa.pub"文件里面的内容拷贝到github上
或者将github上自动生成的公钥拷贝到"C:\User\用户名\id_rsa.pub"文件里都可以
8.初始化仓库
输入以下命令会在当前目录下创建一个名为.git的隐藏目录,这个目录包含了Git仓库的所有必要文件和数据
bash
git init

9.切换为main分支(可选)
输入完"git init"后,会显示"master"分支,但是在github上新建的仓库是"main"分支,可以改一下
bash
git branch -m master main
10.添加至git仓库缓存区
git add .是把当前目录下的所有文件添加到git仓库的缓存区
如果只想添加一个文件"git add README.md"
bash
git add .

11.将暂存区中的内容提交到本地仓库中
"first commit"是注释
bash
git commit -m "first commit"

12.将远程仓库添加到本地
bash
git remote add origin git@github.com:shunqiziranza/ywtools.git
13.将本地文件的推送到远程仓库的main分支上
bash
git push -u origin main

四.刷新github页面
End