git入门:git初尝试01
😂先憋说话。。。。。。。你以为我要说什么?!!!先实践,后理论
新建项目操作——克隆(下载)远程仓库已有项目到本地来操作
1、新建一个新的repo

2、确定创建该项目
一般点选红框的选项,一般需要点选readme.md,拥有一个初始化文件

3、进入项目页面

(1)resame.md
用于项目介绍说明,github自动读取readme.md,把markdown格式自动转成html,展示在页面上
(2)clone or download
use https VS use ss
- use https:每一次操作都需要用户名和密码,较为麻烦
-
use ssh:一般选它作为项目(仓库)的地址,它是一个git协议
image
这里,用我的ssh地址作为项目(仓库)的地址:git@github.com:wxq393/blogtest.git
作为例子进行演示。
4、克隆已有项目
(1)此时打开终端,将use ssh协议下的拷贝下来的项目地址使用命令行进行操作
$ git clone git@github.com:wxq393/blogtest.git
(2)提示错误
fetal:could not read remote repository

(3)设置公钥
插播:设置公钥的终端命令行要写什么?从哪里找?
通常可以从github主页的头像——setting——(左侧选项中)SSH and GPG keys中[generating SSH keys]蓝色链接中(图1)去寻找:
image1
点击之后,选择Generating a new SSH key,即有命令行操作的提示(图3):
image2
image3
这里继续以我的实例讲解:
$ ssh-keygen -t rsa -b 4096 -C "wangxiaoqin.0009@163.com"

(4)出现公钥
$ cat ~/.ssh/id_rsa.pub

(5)返回线上github主页
点击:头像——setting——(左侧选项中)SSH and GPG keys——SSH keys——(右上角绿键)new ssh key

在key中复制粘贴在命令行中的一大串公钥:

确认后需要再填写github的登录密码确认(不要慌):

(6)返回终端
再次用git clone克隆(下载)远程仓库的项目,便会提示克隆成功。
(由于我之前已经设置过公钥了,如果终端出现的提示信息有类似“done”的字眼,即可说明克隆成功。不一定和我一模一样,灵活应对命令行的提示)

5、本地VS远程的文件提交
终端操作切换目录、创建文件、提交本地、推送远程库的一系列过程:

6、返回github项目主页
目的:利用项目setting中的githubpages的功能,将代码文件生成线上可预览的页面
(1)点击项目上的setting,找到githubpages的选项,进行master branch
image
image
(2)此时,save(红框标注)变灰色,并生成一个预览页面的链接(红线标注)

7、想要本地编辑(如写作),push远程github
操作:重复第5步骤,就可以愉快地进行这样的操作了
注:这里面还涉及前面命令行的操作,比如线上vim编辑等,灵活应对。实在写得太细了,我都不好意思再贴图操作了。( ̄▽ ̄)"🤣