Skip to content

Commit 2f6f6fb

Browse files
author
liuhao
committed
增加git内容以及图标
1 parent 287ebc1 commit 2f6f6fb

File tree

9 files changed

+204
-10
lines changed

9 files changed

+204
-10
lines changed

docs/.vuepress/config.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
* 特别的,请不要在两个配置文件中重复配置相同的项,当前文件的配置项会被覆盖
1010
*/
1111

12+
// 统一图标库:https://icon-sets.iconify.design/vscode-icons/
13+
1214
import { viteBundler } from '@vuepress/bundler-vite'
1315
import { defineUserConfig } from 'vuepress'
1416
import { plumeTheme } from 'vuepress-theme-plume'
@@ -125,7 +127,7 @@ export default defineUserConfig({
125127
// youtube: true, // 启用嵌入 youtube视频 语法 @[youtube](video_id)
126128
// artPlayer: true, // 启用嵌入 artPlayer 本地视频 语法 @[artPlayer](url)
127129
// audioReader: true, // 启用嵌入音频朗读功能 语法 @[audioReader](url)
128-
icon: { provider: 'iconify' }, // 启用内置图标语法 ::icon-name::
130+
icon: { provider: 'iconify' }, // 启用内置图标语法 ::icon-name:: https://icon-sets.iconify.design/
129131
// table: true, // 启用表格增强容器语法 ::: table
130132
// codepen: true, // 启用嵌入 codepen 语法 @[codepen](user/slash)
131133
// replit: true, // 启用嵌入 replit 语法 @[replit](user/repl-name)

docs/.vuepress/navbar.ts

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,26 +7,37 @@
77
import { defineNavbarConfig } from 'vuepress-theme-plume'
88

99
export default defineNavbarConfig([
10-
{ text: '首页', link: '/' },
10+
{ text: '首页', link: '/', icon: 'streamline-plump-color:home-1-flat'},
1111
{
1212
text: '编程语言',
1313
items: [
14-
{ text: 'Go', link: '/notes/go/README.md' },
15-
{ text: 'mongoDB', link: '/notes/mongoDB/README.md' },
16-
]
14+
{ text: 'Go', icon:'vscode-icons:file-type-go', link: '/notes/go/README.md' },
15+
],
16+
icon: 'streamline-color:file-code-1'
1717
},
1818
{
1919
text: '中间件',
2020
items: [
21-
{ text: 'docker', link: '/notes/docker/README.md' },
22-
]
21+
{ text: 'mongoDB', icon:'devicon:mongodb', link: '/notes/mongoDB/README.md' },
22+
{ text: 'docker', icon: 'devicon:docker' , link: '/notes/docker/README.md' },
23+
],
24+
icon: 'streamline-plump-color:database-flat'
25+
},
26+
{
27+
text: '开发常用',
28+
items: [
29+
{ text: 'git', icon:'material-icon-theme:git', link: '/notes/git/README.md' },
30+
],
31+
icon: 'streamline-sharp-color:tool-box-flat'
2332
},
2433
{
2534
text: '开源项目',
2635
items: [
2736
{ text: 'go-utils', link: '/notes/utils/README.md' },
28-
]
37+
],
38+
icon: 'mingcute:github-fill'
2939
},
40+
3041
{ text: '标签', link: '/blog/tags/' },
3142
{ text: '归档', link: '/blog/archives/' },
3243
{ text: '博客', link: '/blog/' },

docs/.vuepress/notes.ts

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,18 @@ const utilsNote = defineNoteConfig({
6969
// sidebar: 'auto',
7070
})
7171

72+
const gitNote = defineNoteConfig({
73+
dir: 'git',
74+
// `dir` 所指向的目录中的所有 markdown 文件,其 permalink 需要以 `link` 配置作为前缀
75+
// 如果 前缀不一致,则无法生成侧边栏。
76+
// 所以请确保 markdown 文件的 permalink 都以 `link` 开头
77+
link: '/git',
78+
// 手动配置侧边栏结构
79+
sidebar: 'auto',
80+
// 根据文件结构自动生成侧边栏
81+
// sidebar: 'auto',
82+
})
83+
7284

7385
/**
7486
* 导出所有的 note
@@ -78,5 +90,11 @@ const utilsNote = defineNoteConfig({
7890
export default defineNotesConfig({
7991
dir: 'notes',
8092
link: '/',
81-
notes: [goNote, mongoDBNote, dockerNote, utilsNote],
93+
notes: [
94+
goNote,
95+
mongoDBNote,
96+
dockerNote,
97+
utilsNote,
98+
gitNote
99+
],
82100
})

docs/notes/git/1.git介绍.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
---
2+
title: git介绍
3+
createTime: 2025/09/08 23:47:31
4+
permalink: /git/881498zj/
5+
icon: material-icon-theme:git
6+
---
7+
8+
Git 是由 Linux 的创始人 Linus 发明的。Git 是目前世界上最先进的分布式版本控制系统。
9+
10+
首先需要了解什么是集中式,什么是分布式。
11+
12+
集中式版本控制系统,版本库是集中存放在中央服务器的,每次需要从中央服务器获取最新版本,然后将自己干完的活推送回中央服务器。也就是说,整个项目的最新版代码都集中于中央服务器中。
13+
14+
而且集中式版本控制系统最大的毛病就是必须联网才能工作,如果网络不好,那么就可能出现提交文件时间提交很久,很浪费时间。
15+
16+
分布式版本控制系统他和他的名字一样,是分布式的,也就是说没有中央服务器这一个概念,每一个人的电脑上都有一个完整的版本库。
17+
18+
那么这样如何多人协作呢?
19+
> 比方说你在自己电脑上改了文件 A,你的同事也在他的电脑上改了文件 A,这时,你们俩之间只需把各自的修改推送给对方,就可以互相看到对方的修改了。
20+
21+
在实际使用分布式版本控制系统的时候,其实很少在两人之间的电脑上推送版本库的修改,因为可能你们俩不在一个局域网内,两台电脑互相访问不了,也可能今天你的同事病了,他的电脑压根没有开机。因此,分布式版本控制系统通常也有一台充当“中央服务器”的电脑,但这个服务器的作用仅仅是用来方便“交换”大家的修改,没有它大家也一样干活,只是交换修改不方便而已。
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
---
2+
title: 了解项目状态
3+
createTime: 2025/09/08 23:48:53
4+
permalink: /git/3f1386qi/
5+
icon: material-icon-theme:git
6+
---
7+
8+
## git status
9+
10+
当你忘记某个文件是否已经修改,是否提交到仓库的时候,就可以使用 `git status` 命令来查看。
11+
12+
它帮助我们了解当前工作目录中文件的更改情况,包括哪些文件被修改、新增或删除,以及这些更改是否已提交到版本库。
13+
14+
直接在命令行中输入;
15+
```bash
16+
git status
17+
```
18+
19+
此命令会返回当前工作目录的状态,包括未跟踪的文件、修改后的文件以及新创建的文件。同时,它还会显示当前 branch 的状态信息,如分支名称、最后一次提交的 commit 信息等。
20+
21+
如果你想查看特定文件的状态,可以使用 `git status -a` 命令,它会显示所有文件的状态,**包括那些在 Git 仓库中但已经删除的文件**
22+
23+
`git status` 的优点在于它能够快速展示当前目录的状态,让我们时刻把握项目的进展。然而,它也有一些局限性。例如,**它只能显示当前目录的状态**,无法跨多个子目录分析代码状态。为了解决这个问题,我们可以使用 `git status -u` 命令,它会显示所有子目录的状态。
24+
25+
**例如修改了一个 `readme.txt` 文件,使用命令后**
26+
```bash
27+
On branch master
28+
Changes not staged for commit:
29+
(use "git add <file>..." to update what will be committed)
30+
(use "git checkout -- <file>..." to discard changes in working directory)
31+
32+
modified: readme.txt
33+
34+
no changes added to commit (use "git add" and/or "git commit -a")
35+
```
36+
`On branch master` 表示我们当前所在的分支是 master 分支。
37+
38+
下面的 `Changes not staged for commit:` 告诉我们工作目录中有一些更改尚未提交。Git 将要被提交的更改称为 "staged"。在这种情况下,Git 提醒你需要使用 `git add` 来 "添加" 更改,以便它们被包含在下一次提交中。
39+
40+
`modified: readme.txt` 表示 "readme.txt" 文件已经被修改。修改意味着我们对这个文件进行了修改,但是这些修改尚未被 "添加" 到暂存区。
41+
42+
`no changes added to commit (use "git add" and/or "git commit -a")` 是提示我们还没有把修改添加到下一次提交中。如果我们想把这些修改包含在下次提交中,我们需要使用 `git add` 命令。如果我们想忽略这些未添加的更改,我们可以使用 `git checkout -- readme.txt` 来丢弃工作目录中的更改。
43+
44+
45+
## git diff
46+
47+
只是用 `git status` 只能看文件是否有改动,但是不能看到文件具体改动了哪些,一旦你忘记了修改了什么地方,也就不敢随便乱动,这个时候就可以使用 `git diff` 命令**查看当前工作目录中所有未提交的更改**
48+
49+
如果我们需要查看特定文件的变化,可以使用 `git diff <文件名>`
50+
51+
`git diff --cached` 命令则显示已暂存但对尚未提交到版本库的更改。
52+
53+
例如修改了一个 `example.txt` 文件后,使用 `git diff` 命令来查看:
54+
```bash
55+
diff --git a/example.txt b/example.txt index 843a555..45aff21 100644
56+
--- a/example.txt
57+
+++ b/example.txt
58+
@@ -1,3 +1,4 @@
59+
Line 1: The same as the original version. Line 2: Added a new line.
60+
Line 3: This line has been modified.
61+
+Line 4: Another new line.
62+
```
63+
`diff --git a/example.txt b/example.txt`:这行告诉我们在 a/example.txt 和 b/example.txt 之间进行了比较。
64+
65+
`index 843a555..45aff21 100644`:这行展示了索引信息,它描述了文件在 Git 版本库中的状态。在这个例子中,843a555 和 45aff21 是文件的两个不同的版本标识,100644 是文件的权限模式。
66+
67+
`--- a/example.txt` 和 `+++ b/example.txt`:这两行分别表示被比较的两个文件。在这个例子中,a/example.txt 是原始文件,b/example.txt 是修改后的文件。
68+
69+
`@@ -1,3 +1,4 @@`:这行表示差异比较的行范围。在这个例子中,原始文件的前3行与修改后的文件的前3行是相同的,而修改后的文件新增了一行。
70+
71+
最后面列出了文件的每一行及其状态。"+" 表示新增的行,"%" 表示没有改变的行,"-" 表示被删除的行。
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
---
2+
title: 仓库的创建
3+
createTime: 2025/09/08 23:50:07
4+
permalink: /git/1blzkos1/
5+
icon: material-icon-theme:git
6+
---
7+
8+
仓库又名版本库,英文名字为 Repository,这个仓库里面的所有文件都可以被 Git 管理起来,每个文件的修改、删除,Git 都能跟踪,以便任何时刻都可以追踪历史,或者在将来某个时刻可以“还原”。
9+
10+
## 创建仓库
11+
12+
创建仓库的命令很简单,打开终端,进入某个你想创建仓库的文件夹路径,使用命令:
13+
```bash
14+
git init
15+
```
16+
即可创建成功,创建完成之后是一个空的仓库,而且当前文件夹下面会多一个 `.git` 的目录,这个目录是 Git 来跟踪管理版本库的。
17+
18+
## 将文件放入 Git 仓库
19+
20+
随便在文件夹中创建一个文件 `a.txt`,首先是**将其放入暂存区**
21+
```bash
22+
git add a.txt
23+
```
24+
像这样如果没有报任何错误就代表成功将内容添加到暂存区。
25+
26+
下一步就是将**文件提交到仓库**
27+
```bash
28+
git commit -m "this is a file"
29+
```
30+
`-m` 后面加上双引号写的内容代表的是本次提交的说明。执行了这条命令后,Git **会将暂存区的修改内容提交到版本库,并将附加的描述信息一并记录下来。** 这样,你就可以在历史记录中查看这个提交的详细信息。
31+
32+
我们可以一次性 add 许多个文件,然会一次性 commit 将其提交到仓库:
33+
```bash
34+
git add file2.txt file3.txt
35+
git commit -m "add 3 files."
36+
```

docs/notes/git/4.版本回退.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
---
2+
title: 版本回退
3+
createTime: 2025/09/08 23:50:50
4+
permalink: /git/j9t15o2u/
5+
icon: material-icon-theme:git
6+
---
7+
8+
在了解了如何提交和修改文件之后,我们来看如何实现版本回退,这样就可以放心地对文件进行修改了,哪怕修改后不满意也可以回退到原来的版本。
9+
10+
我们可以使用 `gti log` 追踪我们的版本控制历史,它对于了解项目的历史和追踪变更至关重要。
11+
12+
`git log` 命令:
13+
```bash
14+
git log
15+
```
16+
这会显示从初始提交到最新提交的所有提交记录。每个提交都有一个唯一的哈希值,表示该提交的唯一标识符。
17+
18+
我们还可以使用一些选项来过滤和定制我们想要查看的提交记录。例如,我们可以使用 `--short` 选项来只显示每个提交的简短信息,而不是整个提交记录。
19+
```bash
20+
git log --short
21+
```
22+
23+
我们还可以使用`--graph`选项来显示提交历史的图形化表示,这可以帮助我们更好地理解分支和合并操作。
24+
```bash
25+
git log --graph
26+
```

docs/notes/git/README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
title: git
3+
createTime: 2025/09/08 23:46:44
4+
permalink: /git/
5+
icon: material-icon-theme:git
6+
---
7+
8+
9+
git

docs/notes/utils/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
title: utils
2+
title: go-utils
33
createTime: 2025/09/08 10:16:26
44
permalink: /utils/
55
---

0 commit comments

Comments
 (0)