Merge pull request #41 from nbtca/dev

Dev
This commit is contained in:
clas 2024-10-17 19:49:18 +08:00 committed by GitHub
commit d7274fff0e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 6218 additions and 7078 deletions

View file

@ -60,6 +60,7 @@ export default [
"node_modules/**/*",
"src/utils/active/**/*",
"openapi-ts.active.config.ts",
"src/env.d.ts",
],
},
]

View file

@ -14,57 +14,59 @@
"active": "openapi-ts -f openapi-ts.active.config.ts"
},
"dependencies": {
"@astrojs/react": "^3.3.1",
"@astrojs/rss": "^4.0.5",
"@astrojs/tailwind": "^5.1.0",
"@astrojs/vue": "^4.0.9",
"@fullcalendar/core": "^6.1.11",
"@fullcalendar/daygrid": "^6.1.11",
"@fullcalendar/icalendar": "^6.1.11",
"@fullcalendar/react": "^6.1.11",
"@headlessui/vue": "^1.7.22",
"@logto/browser": "^2.2.16",
"@astrojs/react": "^3.6.2",
"@astrojs/rss": "^4.0.7",
"@astrojs/tailwind": "^5.1.1",
"@astrojs/vue": "^4.5.1",
"@fullcalendar/core": "^6.1.15",
"@fullcalendar/daygrid": "^6.1.15",
"@fullcalendar/icalendar": "^6.1.15",
"@fullcalendar/react": "^6.1.15",
"@headlessui/vue": "^1.7.23",
"@logto/browser": "^2.2.18",
"@nextui-org/react": "^2.4.8",
"@stylistic/eslint-plugin": "^2.1.0",
"astro": "^4.5.12",
"framer-motion": "^11.5.6",
"@stylistic/eslint-plugin": "^2.8.0",
"astro": "^4.15.9",
"framer-motion": "^11.9.0",
"ical.js": "^1.5.0",
"md5": "^2.3.0",
"npm": "^10.8.1",
"openapi-fetch": "^0.10.2",
"qrcode": "^1.5.3",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"rehype": "^13.0.1",
"openapi-fetch": "^0.12.2",
"qrcode": "^1.5.4",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"rehype": "^13.0.2",
"sharp": "^0.33.5",
"tailwindcss": "^3.4.3",
"tailwindcss": "^3.4.13",
"unist-util-visit": "^5.0.0",
"uuid": "^9.0.1",
"vue": "^3.4.21"
"uuid": "10.0.0",
"vue": "^3.5.10"
},
"devDependencies": {
"@astrojs/markdown-remark": "^5.2.0",
"@cspell/eslint-plugin": "^8.8.1",
"@eslint/js": "^9.11.0",
"@hey-api/openapi-ts": "^0.53.3",
"@cspell/eslint-plugin": "^8.14.4",
"@eslint/js": "^9.11.1",
"@hey-api/openapi-ts": "^0.53.5",
"@types/eslint__js": "^8.42.3",
"@types/md5": "^2.3.5",
"@types/qrcode": "^1.5.5",
"@types/react": "^18.2.79",
"@types/react-dom": "^18.2.25",
"@types/uuid": "^9.0.8",
"eslint": "^8.57.0",
"eslint-import-resolver-typescript": "^3.6.1",
"eslint-plugin-astro": "^1.2.0",
"eslint-plugin-import": "^2.29.1",
"globals": "^15.2.0",
"husky": "^9.0.11",
"lint-staged": "^15.2.2",
"openapi-typescript": "^7.0.1",
"typescript": "^5.5.3",
"typescript-eslint": "^7.9.0"
"@types/react": "^18.3.10",
"@types/react-dom": "^18.3.0",
"@types/uuid": "10.0.0",
"eslint": "^8.57.1",
"eslint-import-resolver-typescript": "^3.6.3",
"eslint-plugin-astro": "^1.2.4",
"eslint-plugin-import": "^2.30.0",
"globals": "^15.9.0",
"husky": "^9.1.6",
"lint-staged": "^15.2.10",
"openapi-typescript": "^7.4.1",
"typescript": "^5.6.2",
"typescript-eslint": "8.7.0"
},
"lint-staged": {
"*.{js,jsx,mjs,ts,tsx,mts,astro}": "eslint --fix"
},
"volta": {
"node": "20.17.0"
}
}

File diff suppressed because it is too large Load diff

1
src/env.d.ts vendored
View file

@ -1,3 +1,4 @@
/// <reference path="../.astro/types.d.ts" />
interface ImportMetaEnv {
readonly PUBLIC_SITE_URL: string
readonly PUBLIC_LOGTO_CALLBACK_URL: string

View file

@ -0,0 +1,162 @@
---
layout: "../../../../../layouts/MarkdownPost.astro"
title: 'Git 基本流程'
pubDate: 2024-10-13
description: ' '
author: 'zzh0u'
tags: ["开发","Git"]
theme: 'white'
featured: true
---
Git 是一个版本控制系统,帮助用户在项目中追踪文件修改,并在需要时能够还原到之前操作。本文介绍了 Git 的基本流程,包括初始化、添加、提交、推送、拉取等操作。
## 初始化
首先,需要在本地创建一个空文件夹,然后在该文件夹下执行 `git init` 命令,这将创建一个 `.git` 目录,里面包含了 Git 的所有配置信息。然后通过 `touch` 命令新建一个`.txt`文件,并在文件中输入任意内容:
```
McDonald's
Hamburger
Coke
```
## 第一次 commit
`.txt` 文件中输入内容后,可以执行 `git status` 命令查看当前文件状态:
```
On branch main
No commits yet
Untracked files:
(use "git add <file>..." to include in what will be committed)
text.txt
nothing added to commit but untracked files present (use "git add" to track)
```
可以看到文件处于未跟踪状态Untracked。这里引出 `Git` 中文件的第一种状态:**未跟踪状态Untracked**。需要执行 `git add` 命令将文件添加到暂存区。执行 `git add text.txt` 命令后,再次执行 `git status` 命令,可以看到:
```
On branch main
No commits yet
Changes to be committed:
(use "git rm --cached <file>..." to unstage)
new file: text.txt
```
可以看到,文件已被添加到暂存区,等待提交。这里引出第二种状态:**暂存状态Staged**。暂存区Stage是 Git 用来暂存文件的地方。现在我们需要执行 `git commit -m "first commit"` 命令提交文件,`-m` 参数后面是提交信息。也可以不加参数,直接执行 `git commit` 命令,这时会打开默认编辑器,输入提交信息。这个时候再次执行 `git status` 命令,可以看到:
```
On branch main
nothing to commit, working tree clean
```
可以看到,暂存区已经清空,工作区也没有未提交的修改。这个时候,所有的文件都属于第三种状态:**已提交状态Committed**。至此,第一次 `commit` 圆满完成。
## 你可以吃后悔药
首先,我们现在自己的仓库多提交了几次 `commit` 之后,内容如下:
```
McDonald's
Hamburger
Coke
fries
Chicken Nuggets
```
这个时候再次执行 `git status` 命令,可以看到:
```
commit b3e4e008af045743defb01ca55b2ddd47c6926e4 (HEAD -> main)
Author: zzh0u <weirong.zhou@outlook.com>
Date: Sun Oct 13 09:44:57 2024 +0800
third commit
commit 5c644068ce2184f5b4627aecd77462411355ec4e
Author: zzh0u <weirong.zhou@outlook.com>
Date: Sun Oct 13 09:43:04 2024 +0800
second commit
commit 6ccffbb33c7574c27f9a34b1812a5fef1af08696
Author: zzh0u <weirong.zhou@outlook.com>
Date: Sun Oct 13 09:32:00 2024 +0800
first commit
```
可以看到,当前仓库有三个 `commit`,当然,如果你觉得输出太多,眼花缭乱,可以加上 `--oneline` 参数,输出简洁版:
```
b3e4e00 (HEAD -> main) third commit
5c64406 second commit
6ccffbb first commit
```
oops! 突然我又没那么想吃鸡块了,想回到上一次提交,怎么办?要回到第二个 commit你可以运行 git reset 命令,后面跟上 commit 的 ID`git reset 5c64406`,注意这里是**第二次**提交的 ID。做完这一步你可能会满心欢喜的打开文本文档但很抱歉这个时候文件还是原来的样子一如刚提交完第三次 `commit` 时候的样子,你满心疑惑,这到底是怎么回事?于是你又执行 `git status`:
```
On branch main
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: text.txt
no changes added to commit (use "git add" and/or "git commit -a")
```
这时候你注意到终端的 `Git` 提示你现在的状态是 `not staged`,这就引出了第四种状态:**未暂存状态Unstaged**。但是别急,不信你试试 `git log --oneline` 命令,第三次提交不会出现在提交日志中:
```
5c64406 (HEAD -> main) second commit
6ccffbb first commit
```
我们已经成功回到的之前的 `commit` 了。如果你想撤销一个 commit**并撤销该提交之后的所有修改**,你可以在 git reset 命令中加上 --hard 标志。让我们测试一下这个方法,回到第一个 commit执行 `git reset 6ccffbb --hard`,这就会回到第一次修改的样子:
```
McDonald's
Hamburger
Coke
```
我们又回到了指定提交时的文件初始状态。所有在那次 `commit` 之后对文件所做的修改都被删除。当我们检查提交日志时,我们将只看到第一次 `commit`
## 另类的后悔药
我已经重新回到了刚提交过三次 `commit` 后的状态:
```
d3b86b2 (HEAD -> main) third commit
5aac07d second commit
6ccffbb first commit
```
这次我们试试另外一个命令 `git revert`,同时输入当前提交的 ID。在我的例子中我们使用最新的那个 `commit` 的 ID
```
git revert d3b86b2
```
这个命令会撤销指定提交,同时还会创建一个新的提交,记录撤销操作。执行完这个命令后,我们再次查看提交日志:
```
ddc8aa6 (HEAD -> main) Revert "third commit"
d3b86b2 third commit
5aac07d second commit
6ccffbb first commit
```
可以看到,新的提交记录了**撤销操作**,同时**保留**了之前的提交记录。这就是 `git revert` 命令的作用。
想必聪明的读者看到这里已经懂了,`git reset` 会直接回到某个 `commit` 的状态,并且直接删除之后的所有提交记录;而 `git revert` 则会创建一个新的提交,保留之前的提交记录,并记录撤销操作。不过虽然 `git revert` 很方便,但是也要注意不要滥用,它会引入新的提交记录,在团队合作中可能会造成混乱。
## Ps
1. 推荐阅读:[freeCodeCamp](https://www.freecodecamp.org/chinese/news/git-reverting-to-previous-commit-how-to-revert-to-last-commit/)
2. 大家可以试试 `git reset --soft` 命令,看看它是怎么回事。
3. 我刚想到一个骚操作,就是 `revert` 我上一次的 `revert`,什么俄罗斯套娃哈哈哈。
4. 远程仓库的操作,先挖坑吧,以后有时间再写:-
5. 硬重置后的恢复又挖一个坑orz