diff --git "a/content/posts/tool/Mac\345\237\272\347\241\200\350\256\276\346\226\275\345\222\214\346\225\210\347\216\207.md" "b/content/posts/daily/Mac\345\237\272\347\241\200\350\256\276\346\226\275\345\222\214\346\225\210\347\216\207.md" similarity index 100% rename from "content/posts/tool/Mac\345\237\272\347\241\200\350\256\276\346\226\275\345\222\214\346\225\210\347\216\207.md" rename to "content/posts/daily/Mac\345\237\272\347\241\200\350\256\276\346\226\275\345\222\214\346\225\210\347\216\207.md" diff --git "a/content/posts/daily/\346\234\211\350\266\243\347\232\204bug.md" "b/content/posts/daily/bugs/\346\234\211\350\266\243\347\232\204bug.md" similarity index 99% rename from "content/posts/daily/\346\234\211\350\266\243\347\232\204bug.md" rename to "content/posts/daily/bugs/\346\234\211\350\266\243\347\232\204bug.md" index 520d2ac..a10d765 100644 --- "a/content/posts/daily/\346\234\211\350\266\243\347\232\204bug.md" +++ "b/content/posts/daily/bugs/\346\234\211\350\266\243\347\232\204bug.md" @@ -8,7 +8,7 @@ categories: ['bug🐞'] --- ## 背景 - +s 我司某个项目一开始是基于 vue3 进行开发的,使用的是开源的 antd UI 组件库,结果开发完了,领导说界面要与公司主产品的 UI 契合,也就是说要改用公司的组件库,然而公司的组件库是基于 react 的,没有办法只能对整个项目进行重构。 项目选型:`React@18.2.0 + react-router@6.11.0 + rematch@2.2.0 + typescript@5.0.4 tailwindss@3.3.3`,基于 `webpack5` 搭建了一套脚手架。 diff --git a/content/posts/z-drafts/english/en.md b/content/posts/daily/english/en.md similarity index 100% rename from content/posts/z-drafts/english/en.md rename to content/posts/daily/english/en.md diff --git "a/content/posts/daily/git\350\207\252\347\224\250\346\211\213\345\206\214.md" "b/content/posts/daily/git\350\207\252\347\224\250\346\211\213\345\206\214.md" new file mode 100644 index 0000000..bbf64f7 --- /dev/null +++ "b/content/posts/daily/git\350\207\252\347\224\250\346\211\213\345\206\214.md" @@ -0,0 +1,184 @@ +--- +title: 'Git 自用手册' +date: 2022-09-19 +lastmod: 2024-05-07 +series: [] +categories: [tool] +weight: +--- + +**本文基于 git version 2.32.0** + +--- + +当然,许多人选择使用 SourceTree 这样的图形界面来管理版本,但我作为一个习惯使用命令行和喜欢简约风格的人,更喜欢在终端中输入命令来进行 Git 相关操作。在这篇文章中,我将分享我这几年来常用的命令和经验。(一些基础的知识就不在本文中赘述了,可以自行网上搜索资料。) + +## 基础配置 + +### 配置别名 + +别名可以极大简化命令号的操作复杂度~~~,是我换电脑或者重做系统后的必做的待办项之一。 + +```sh {open=true, lineNos=false, wrap=false, header=true, title="常用别名"} +# 请直接复制进 terminal 执行一下即可。提高幸福度的别名使用⭐️标记。 +# -------------------------------------------------------------------------------------- +# 常规 +git config --global alias.g git +git config --global alias.c 'config' # g c user.name eric +git config --global alias.cg 'config --global' # g cg user.email eric@gmail.com + +# 对于大型仓库只 clone 对应分支, g cloneb [bracnchName | tagName] [url] ⭐️ +g cg alias.cloneb 'clone --single-branch --branch' + +g cg alias.st status # 常用,提交前看一眼大致变化 +g cg alias.ad 'add -A' +g cg alias.cm 'commit -m' +g cg alias.ps push +g cg alias.pso 'push origin' +g cg alias.pl pull +g cg alias.plo 'pull origin' + +g cg alias.cam 'commit --amend -m' # 修改最后一次 commit(⭐️会变更commitId) +g cg alias.can 'commit --amend --no-edit' # 追加修改,不加新 commit(g can ⭐️ 经常使用了属于是) + +# 查看配置 +g cg alias.cl 'config --list' +g cg alias.cgl 'config --global --list' +g cg alias.cll 'config --local --list' # 查看当前仓库下的 git 配置 + +# -------------------------------------------------------------------------------------- +# 分支相关 (对于很多新手都不清楚的是:branchName 也只是一个指针!!!s) +g cg alias.br branch +g cg alias.rename 'branch --move' # g rename oldname newname +g cg alias.ck checkout # 带着 HEAD 到处跑~(⭐️ g ck - 快速返回上一个分支,同理 g merge -) +g cg alias.cb 'checkout -b' +g cg alias.db 'branch -d' # 删除分支 +g cg alias.fdb 'branch -D' # 强制删除 +g cg alias.drb 'push origin --delete' # 删除远程 g drb brname ⭐️; 也可以推送一个空本地分支: g pso :brname + +# -------------------------------------------------------------------------------------- +# tag 相关 +# 打 tag: g tag [tagName] +# 推 tag: tag: g pso [tagName] +g cg alias.psot 'push origin --tags' # 推多个 tag +g cg alias.dt 'tag -d' # 删除 tag +g cg alias.drt 'push origin --delete' # 删除远程 tag 也可以推送空tag g pso :refs/tags/[version] + +# -------------------------------------------------------------------------------------- +# 进阶操作 +# 常用 ⭐️,开发到一半要去改 bug 🙅🏻‍♀️ +g cg alias.sta stash +g cg alias.stap 'stash pop' + +g cg alias.rv 'revert' # 反向操作,产生新的 commit +# 下面的 reset 是移动分支指针,并移出之后的 commit,同时还带有一点副作用 +g cg alias.rh 'reset --hard' # 副作用:会重置暂存区和工作区 +g cg alias.rs 'reset --soft' # 副作用:不会重置暂存区和工作区 +# g reset --mixed commitId # 副作用:重置暂存区,工作区不变,是 reset 的默认方式 +g cg alias.cp cherry-pick # g cp [commit/brname] 如果是 brname 则是把该分支最新commit合并(再次验证 brname 也就是一个指针~) +# cp 区间 g cp commitA..commitB 把区间 (A, B] 的 commit 都合进来,A 早于 B 的 +# cp 区间 g cp commitA^..commitB 把区间 [A, B] 的 commit 都合进来 +# git reflog 时光机神器~~~~~~~~~~~~~~能查看HEAD指针行走的所有轨迹,包括因为reset而被移出的commit +# 有了 reflog:cherry-pick 轻松找回被删除的 commit,reset 后悔了也可以轻松地回到未来 + +# 变基开启交互模式 g ri cmid +g cg alias.ri 'rebase -i' + +# -------------------------------------------------------------------------------------- +# log 美化 +g cg alias.lg "log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit" +# 根据 commit 内容查找 commit +g cg alias.find "log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --grep" +# 根据 commit 用户查找 commit +g cg alias.findby "log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --author" + +# -------------------------------------------------------------------------------------- +# 不常用命令(2.23 新增) +# git restore / restore --staged [filename] +# get switch / switch -c [brname] +``` + +> 注意:reflog 查看的是本地历史,在别的电脑上是看不见的,同理如果电脑坏了,那么再也回不到未来了...另外,git reflog 不会永远保持,Git 会定期清理那些 “用不到的” 对象,不要指望几个月前的提交还一直在那里。 + +### 配置用户信息 + +命令简化完后,需要配置下个人信息,我个人习惯是公司的项目都单独配置,全局给自己用。 + +```sh {open=true, lineNos=false, wrap=false, header=true, title=""} +# 全局配置 +g cg user.name 'yourname' +g cg user.email 'yourmail@xx.com' + +# 独立配置 +g c user.name 'yourname' +g c user.email 'yourmail@xx.com' +``` + +### HEAD 知多少 + +说一下个人的认知: + +- git 整个 commit 就是一个多叉树 +- 每一个 branch 就是一条新的分支,它的 branchName 也是一个指针,指向的这条分支上最新的 commit +- 每一个 tag 也都可以看成是对应 commit 的别名 + +而 HEAD 是特殊的指针,指向的是当前所在 commit。平时 checkout 操作的就是 HEAD,而 reset 一般操作的是 branchName(HEAD 被迫跟着一起回退) + +常用的 HEAD 简写 `HEAD^n` 与 `HEAD~n`: + +- HEAD^^^ 等价于 HEAD~3 表示父父父提交 +- HEAD^3 表示的是父提交的第三个提交,即合并进来的其他提交 + +--- + + + +## 提交规范 + +通过 `husky` + `lint-staged` 配合来进行约束,详细配置根据项目来设定。 + +## 常见问题 + +### git log 中文字符乱码 + +当 vscode terminal 内使用 `g lg` 出现中文字符乱码问题, 可以去这么配置 + +```yml {c=false} +# ~/.gitconfig +export LC_ALL=zh_CN.UTF-8 +export LANG=zh_CN.UTF-8 +export LESSHARESET=utf-8 +``` + +### 处理拒绝合并不相关历史 + +`fatal: refusing to merge unrelated histories` + +```sh {lineNos=false} +g plo develop --allow-unrelated-histories +``` + +## 参考 + +- [Pro Git 2nd Edition](https://git-scm.com) +- [“纸上谈兵”之 Git 原理](https://mp.weixin.qq.com/s/FSBEM2GqhpVJ6yw9FkxnGA) +- [Git Tools - Submodules](https://git-scm.com/book/en/v2/Git-Tools-Submodules) +- [Git submodule 子模块的管理和使用](https://www.jianshu.com/p/9000cd49822c) diff --git a/content/posts/base-css/.DS_Store b/content/posts/eight-legged essay/base-css/.DS_Store similarity index 100% rename from content/posts/base-css/.DS_Store rename to content/posts/eight-legged essay/base-css/.DS_Store diff --git a/content/posts/base-css/BFC.md b/content/posts/eight-legged essay/base-css/BFC.md similarity index 100% rename from content/posts/base-css/BFC.md rename to content/posts/eight-legged essay/base-css/BFC.md diff --git a/content/posts/base-css/SC.md b/content/posts/eight-legged essay/base-css/SC.md similarity index 100% rename from content/posts/base-css/SC.md rename to content/posts/eight-legged essay/base-css/SC.md diff --git a/content/posts/base-css/flex.md b/content/posts/eight-legged essay/base-css/flex.md similarity index 100% rename from content/posts/base-css/flex.md rename to content/posts/eight-legged essay/base-css/flex.md diff --git "a/content/posts/base-css/\347\273\217\345\205\270\344\270\211\346\240\217\345\270\203\345\261\200.md" "b/content/posts/eight-legged essay/base-css/\347\273\217\345\205\270\344\270\211\346\240\217\345\270\203\345\261\200.md" similarity index 100% rename from "content/posts/base-css/\347\273\217\345\205\270\344\270\211\346\240\217\345\270\203\345\261\200.md" rename to "content/posts/eight-legged essay/base-css/\347\273\217\345\205\270\344\270\211\346\240\217\345\270\203\345\261\200.md" diff --git "a/content/posts/base-html/JS\345\205\263\344\272\216DOM\351\203\250\345\210\206.md" "b/content/posts/eight-legged essay/base-html/JS\345\205\263\344\272\216DOM\351\203\250\345\210\206.md" similarity index 66% rename from "content/posts/base-html/JS\345\205\263\344\272\216DOM\351\203\250\345\210\206.md" rename to "content/posts/eight-legged essay/base-html/JS\345\205\263\344\272\216DOM\351\203\250\345\210\206.md" index f60d9ef..68c7f0f 100644 --- "a/content/posts/base-html/JS\345\205\263\344\272\216DOM\351\203\250\345\210\206.md" +++ "b/content/posts/eight-legged essay/base-html/JS\345\205\263\344\272\216DOM\351\203\250\345\210\206.md" @@ -16,9 +16,9 @@ tags: [HTML, DOM] offsetParent: 获取最近的祖先: -- position 为 absolute,relative 或 fixed -- 或 body -- 或 table, th, td +- position 为 absolute,relative 或 fixed +- 或 body +- 或 table, th, td offsetTop/offsetLeft: 元素带 border 相对于最近的祖先偏移距离 @@ -47,20 +47,20 @@ content + padding 的宽度,不包括滚动条 ## 滚动 ```js -scrollBy(x,y) // 相对自身偏移 -scrollTo(pageX,pageY) // 滚动到绝对坐标 +scrollBy(x, y) // 相对自身偏移 +scrollTo(pageX, pageY) // 滚动到绝对坐标 scrollToView() // 滚到视野里 ``` ## 常用的操作 -- 判断是否触底(无限加载之类):`offsetHeight + scrollTop >= scollHeight` -- 判断是否进入可视区域(懒加载图片之类):`offsetTop < clientHeight + scrollTop` +- 判断是否触底(无限加载之类):`offsetHeight + scrollTop >= scollHeight` +- 判断是否进入可视区域(懒加载图片之类):`元素的offsetTop - wrap的scrollTop < 窗口clientHeight` ## 坐标 -- clientX/clientY 相对于窗口 -- pageX/pageY 相对于文档 +- clientX/clientY 相对于窗口 +- pageX/pageY 相对于文档 一个 API `dom.getBoundingClientRect()` @@ -70,6 +70,6 @@ scrollToView() // 滚到视野里 ## 获取 dom 样式的方式 -- dom.style,获取行内样式,并且可以修改 -- dom.currentStyle,只能获取样式 -- windwo.getComputedStyle(dom),只能获取样式(IE 兼容较差) +- dom.style,获取行内样式,并且可以修改 +- dom.currentStyle,只能获取样式 +- windwo.getComputedStyle(dom),只能获取样式(IE 兼容较差) diff --git "a/content/posts/base-html/JS\345\205\263\344\272\216DOM\351\203\250\345\210\2062.md" "b/content/posts/eight-legged essay/base-html/JS\345\205\263\344\272\216DOM\351\203\250\345\210\2062.md" similarity index 100% rename from "content/posts/base-html/JS\345\205\263\344\272\216DOM\351\203\250\345\210\2062.md" rename to "content/posts/eight-legged essay/base-html/JS\345\205\263\344\272\216DOM\351\203\250\345\210\2062.md" diff --git "a/content/posts/base-html/script\346\240\207\347\255\276.md" "b/content/posts/eight-legged essay/base-html/script\346\240\207\347\255\276.md" similarity index 100% rename from "content/posts/base-html/script\346\240\207\347\255\276.md" rename to "content/posts/eight-legged essay/base-html/script\346\240\207\347\255\276.md" diff --git "a/content/posts/base-html/\351\241\265\351\235\242\347\224\237\345\221\275\345\221\250\346\234\237.md" "b/content/posts/eight-legged essay/base-html/\351\241\265\351\235\242\347\224\237\345\221\275\345\221\250\346\234\237.md" similarity index 100% rename from "content/posts/base-html/\351\241\265\351\235\242\347\224\237\345\221\275\345\221\250\346\234\237.md" rename to "content/posts/eight-legged essay/base-html/\351\241\265\351\235\242\347\224\237\345\221\275\345\221\250\346\234\237.md" diff --git "a/content/posts/tool/CommonJS\345\222\214ESM.md" "b/content/posts/eight-legged essay/base-js/CommonJS\345\222\214ESM.md" similarity index 100% rename from "content/posts/tool/CommonJS\345\222\214ESM.md" rename to "content/posts/eight-legged essay/base-js/CommonJS\345\222\214ESM.md" diff --git a/content/posts/base-js/EventLoop.md b/content/posts/eight-legged essay/base-js/EventLoop.md similarity index 100% rename from content/posts/base-js/EventLoop.md rename to content/posts/eight-legged essay/base-js/EventLoop.md diff --git "a/content/posts/base-js/Map\345\222\214Set.md" "b/content/posts/eight-legged essay/base-js/Map\345\222\214Set.md" similarity index 100% rename from "content/posts/base-js/Map\345\222\214Set.md" rename to "content/posts/eight-legged essay/base-js/Map\345\222\214Set.md" diff --git a/content/posts/base-js/async&await.md b/content/posts/eight-legged essay/base-js/async&await.md similarity index 100% rename from content/posts/base-js/async&await.md rename to content/posts/eight-legged essay/base-js/async&await.md diff --git a/content/posts/tool/babel.md b/content/posts/eight-legged essay/base-js/babel.md similarity index 100% rename from content/posts/tool/babel.md rename to content/posts/eight-legged essay/base-js/babel.md diff --git "a/content/posts/base-js/curry\345\222\214compose.md" "b/content/posts/eight-legged essay/base-js/curry\345\222\214compose.md" similarity index 100% rename from "content/posts/base-js/curry\345\222\214compose.md" rename to "content/posts/eight-legged essay/base-js/curry\345\222\214compose.md" diff --git a/content/posts/base-js/promiseA+.md b/content/posts/eight-legged essay/base-js/promiseA+.md similarity index 100% rename from content/posts/base-js/promiseA+.md rename to content/posts/eight-legged essay/base-js/promiseA+.md diff --git "a/content/posts/base-js/promise\345\271\266\345\217\221.md" "b/content/posts/eight-legged essay/base-js/promise\345\271\266\345\217\221.md" similarity index 100% rename from "content/posts/base-js/promise\345\271\266\345\217\221.md" rename to "content/posts/eight-legged essay/base-js/promise\345\271\266\345\217\221.md" diff --git "a/content/posts/base-js/promise\346\217\220\345\211\215\347\273\223\346\235\237.md" "b/content/posts/eight-legged essay/base-js/promise\346\217\220\345\211\215\347\273\223\346\235\237.md" similarity index 100% rename from "content/posts/base-js/promise\346\217\220\345\211\215\347\273\223\346\235\237.md" rename to "content/posts/eight-legged essay/base-js/promise\346\217\220\345\211\215\347\273\223\346\235\237.md" diff --git "a/content/posts/base-js/v8\345\236\203\345\234\276\345\233\236\346\224\266\346\234\272\345\210\266.md" "b/content/posts/eight-legged essay/base-js/v8\345\236\203\345\234\276\345\233\236\346\224\266\346\234\272\345\210\266.md" similarity index 100% rename from "content/posts/base-js/v8\345\236\203\345\234\276\345\233\236\346\224\266\346\234\272\345\210\266.md" rename to "content/posts/eight-legged essay/base-js/v8\345\236\203\345\234\276\345\233\236\346\224\266\346\234\272\345\210\266.md" diff --git "a/content/posts/base-js/\345\256\271\346\230\223\345\277\275\347\225\245\347\232\204API.md" "b/content/posts/eight-legged essay/base-js/\345\256\271\346\230\223\345\277\275\347\225\245\347\232\204API.md" similarity index 100% rename from "content/posts/base-js/\345\256\271\346\230\223\345\277\275\347\225\245\347\232\204API.md" rename to "content/posts/eight-legged essay/base-js/\345\256\271\346\230\223\345\277\275\347\225\245\347\232\204API.md" diff --git "a/content/posts/base-js/\345\256\271\346\230\223\346\267\267\346\267\206\347\232\204API.md" "b/content/posts/eight-legged essay/base-js/\345\256\271\346\230\223\346\267\267\346\267\206\347\232\204API.md" similarity index 100% rename from "content/posts/base-js/\345\256\271\346\230\223\346\267\267\346\267\206\347\232\204API.md" rename to "content/posts/eight-legged essay/base-js/\345\256\271\346\230\223\346\267\267\346\267\206\347\232\204API.md" diff --git "a/content/posts/base-js/\345\270\270\347\224\250\345\206\205\347\275\256\345\216\237\347\220\206.md" "b/content/posts/eight-legged essay/base-js/\345\270\270\347\224\250\345\206\205\347\275\256\345\216\237\347\220\206.md" similarity index 100% rename from "content/posts/base-js/\345\270\270\347\224\250\345\206\205\347\275\256\345\216\237\347\220\206.md" rename to "content/posts/eight-legged essay/base-js/\345\270\270\347\224\250\345\206\205\347\275\256\345\216\237\347\220\206.md" diff --git "a/content/posts/tool/\346\267\261\345\205\245npm_script.md" "b/content/posts/eight-legged essay/base-js/\346\267\261\345\205\245npm_script.md" similarity index 100% rename from "content/posts/tool/\346\267\261\345\205\245npm_script.md" rename to "content/posts/eight-legged essay/base-js/\346\267\261\345\205\245npm_script.md" diff --git "a/content/posts/tool/\346\267\261\345\205\245package.json.md" "b/content/posts/eight-legged essay/base-js/\346\267\261\345\205\245package.json.md" similarity index 100% rename from "content/posts/tool/\346\267\261\345\205\245package.json.md" rename to "content/posts/eight-legged essay/base-js/\346\267\261\345\205\245package.json.md" diff --git "a/content/posts/base-js/\350\200\201\347\224\237\345\270\270\350\260\210-This.md" "b/content/posts/eight-legged essay/base-js/\350\200\201\347\224\237\345\270\270\350\260\210-This.md" similarity index 100% rename from "content/posts/base-js/\350\200\201\347\224\237\345\270\270\350\260\210-This.md" rename to "content/posts/eight-legged essay/base-js/\350\200\201\347\224\237\345\270\270\350\260\210-This.md" diff --git "a/content/posts/base-js/\350\200\201\347\224\237\345\270\270\350\260\210-\345\216\237\345\236\213\351\223\276\345\222\214\347\273\247\346\211\277.md" "b/content/posts/eight-legged essay/base-js/\350\200\201\347\224\237\345\270\270\350\260\210-\345\216\237\345\236\213\351\223\276\345\222\214\347\273\247\346\211\277.md" similarity index 100% rename from "content/posts/base-js/\350\200\201\347\224\237\345\270\270\350\260\210-\345\216\237\345\236\213\351\223\276\345\222\214\347\273\247\346\211\277.md" rename to "content/posts/eight-legged essay/base-js/\350\200\201\347\224\237\345\270\270\350\260\210-\345\216\237\345\236\213\351\223\276\345\222\214\347\273\247\346\211\277.md" diff --git "a/content/posts/base-js/\350\200\201\347\224\237\345\270\270\350\260\210-\351\227\255\345\214\205.md" "b/content/posts/eight-legged essay/base-js/\350\200\201\347\224\237\345\270\270\350\260\210-\351\227\255\345\214\205.md" similarity index 100% rename from "content/posts/base-js/\350\200\201\347\224\237\345\270\270\350\260\210-\351\227\255\345\214\205.md" rename to "content/posts/eight-legged essay/base-js/\350\200\201\347\224\237\345\270\270\350\260\210-\351\227\255\345\214\205.md" diff --git "a/content/posts/base-js/\350\200\201\347\224\237\345\270\270\350\260\210-\351\232\220\345\274\217\350\275\254\346\215\242.md" "b/content/posts/eight-legged essay/base-js/\350\200\201\347\224\237\345\270\270\350\260\210-\351\232\220\345\274\217\350\275\254\346\215\242.md" similarity index 100% rename from "content/posts/base-js/\350\200\201\347\224\237\345\270\270\350\260\210-\351\232\220\345\274\217\350\275\254\346\215\242.md" rename to "content/posts/eight-legged essay/base-js/\350\200\201\347\224\237\345\270\270\350\260\210-\351\232\220\345\274\217\350\275\254\346\215\242.md" diff --git "a/content/posts/base-js/\350\247\202\345\257\237\350\200\205\345\222\214\345\217\221\345\270\203\350\256\242\351\230\205.md" "b/content/posts/eight-legged essay/base-js/\350\247\202\345\257\237\350\200\205\345\222\214\345\217\221\345\270\203\350\256\242\351\230\205.md" similarity index 100% rename from "content/posts/base-js/\350\247\202\345\257\237\350\200\205\345\222\214\345\217\221\345\270\203\350\256\242\351\230\205.md" rename to "content/posts/eight-legged essay/base-js/\350\247\202\345\257\237\350\200\205\345\222\214\345\217\221\345\270\203\350\256\242\351\230\205.md" diff --git "a/content/posts/base-js/\350\256\276\350\256\241\346\250\241\345\274\217--\345\210\233\345\273\272\345\236\213.md" "b/content/posts/eight-legged essay/base-js/\350\256\276\350\256\241\346\250\241\345\274\217--\345\210\233\345\273\272\345\236\213.md" similarity index 100% rename from "content/posts/base-js/\350\256\276\350\256\241\346\250\241\345\274\217--\345\210\233\345\273\272\345\236\213.md" rename to "content/posts/eight-legged essay/base-js/\350\256\276\350\256\241\346\250\241\345\274\217--\345\210\233\345\273\272\345\236\213.md" diff --git "a/content/posts/base-js/\350\256\276\350\256\241\346\250\241\345\274\217--\347\273\223\346\236\204\345\236\213.md" "b/content/posts/eight-legged essay/base-js/\350\256\276\350\256\241\346\250\241\345\274\217--\347\273\223\346\236\204\345\236\213.md" similarity index 100% rename from "content/posts/base-js/\350\256\276\350\256\241\346\250\241\345\274\217--\347\273\223\346\236\204\345\236\213.md" rename to "content/posts/eight-legged essay/base-js/\350\256\276\350\256\241\346\250\241\345\274\217--\347\273\223\346\236\204\345\236\213.md" diff --git "a/content/posts/base-js/\350\256\276\350\256\241\346\250\241\345\274\217--\350\241\214\344\270\272\345\236\213.md" "b/content/posts/eight-legged essay/base-js/\350\256\276\350\256\241\346\250\241\345\274\217--\350\241\214\344\270\272\345\236\213.md" similarity index 100% rename from "content/posts/base-js/\350\256\276\350\256\241\346\250\241\345\274\217--\350\241\214\344\270\272\345\236\213.md" rename to "content/posts/eight-legged essay/base-js/\350\256\276\350\256\241\346\250\241\345\274\217--\350\241\214\344\270\272\345\236\213.md" diff --git "a/content/posts/base-js/\351\207\215\345\255\246TypeScript.md" "b/content/posts/eight-legged essay/base-js/\351\207\215\345\255\246TypeScript.md" similarity index 100% rename from "content/posts/base-js/\351\207\215\345\255\246TypeScript.md" rename to "content/posts/eight-legged essay/base-js/\351\207\215\345\255\246TypeScript.md" diff --git "a/content/posts/base-js/\351\230\262\346\212\226\350\212\202\346\265\201.md" "b/content/posts/eight-legged essay/base-js/\351\230\262\346\212\226\350\212\202\346\265\201.md" similarity index 100% rename from "content/posts/base-js/\351\230\262\346\212\226\350\212\202\346\265\201.md" rename to "content/posts/eight-legged essay/base-js/\351\230\262\346\212\226\350\212\202\346\265\201.md" diff --git "a/content/posts/http/TCP-IP\347\275\221\347\273\234\346\250\241\345\236\213.md" "b/content/posts/eight-legged essay/http/TCP-IP\347\275\221\347\273\234\346\250\241\345\236\213.md" similarity index 100% rename from "content/posts/http/TCP-IP\347\275\221\347\273\234\346\250\241\345\236\213.md" rename to "content/posts/eight-legged essay/http/TCP-IP\347\275\221\347\273\234\346\250\241\345\236\213.md" diff --git "a/content/posts/http/XSS\345\222\214CSRF.md" "b/content/posts/eight-legged essay/http/XSS\345\222\214CSRF.md" similarity index 100% rename from "content/posts/http/XSS\345\222\214CSRF.md" rename to "content/posts/eight-legged essay/http/XSS\345\222\214CSRF.md" diff --git "a/content/posts/http/http\345\211\215\344\270\226\344\273\212\347\224\237.md" "b/content/posts/eight-legged essay/http/http\345\211\215\344\270\226\344\273\212\347\224\237.md" similarity index 100% rename from "content/posts/http/http\345\211\215\344\270\226\344\273\212\347\224\237.md" rename to "content/posts/eight-legged essay/http/http\345\211\215\344\270\226\344\273\212\347\224\237.md" diff --git "a/content/posts/http/\345\270\270\350\247\201\347\212\266\346\200\201\347\240\201.md" "b/content/posts/eight-legged essay/http/\345\270\270\350\247\201\347\212\266\346\200\201\347\240\201.md" similarity index 100% rename from "content/posts/http/\345\270\270\350\247\201\347\212\266\346\200\201\347\240\201.md" rename to "content/posts/eight-legged essay/http/\345\270\270\350\247\201\347\212\266\346\200\201\347\240\201.md" diff --git "a/content/posts/http/\346\265\217\350\247\210\345\231\250\347\274\223\345\255\230.md" "b/content/posts/eight-legged essay/http/\346\265\217\350\247\210\345\231\250\347\274\223\345\255\230.md" similarity index 100% rename from "content/posts/http/\346\265\217\350\247\210\345\231\250\347\274\223\345\255\230.md" rename to "content/posts/eight-legged essay/http/\346\265\217\350\247\210\345\231\250\347\274\223\345\255\230.md" diff --git "a/content/posts/http/\350\267\250\345\237\237.md" "b/content/posts/eight-legged essay/http/\350\267\250\345\237\237.md" similarity index 100% rename from "content/posts/http/\350\267\250\345\237\237.md" rename to "content/posts/eight-legged essay/http/\350\267\250\345\237\237.md" diff --git "a/content/posts/http/\350\276\223\345\205\245url\345\210\260\346\270\262\346\237\223.md" "b/content/posts/eight-legged essay/http/\350\276\223\345\205\245url\345\210\260\346\270\262\346\237\223.md" similarity index 100% rename from "content/posts/http/\350\276\223\345\205\245url\345\210\260\346\270\262\346\237\223.md" rename to "content/posts/eight-legged essay/http/\350\276\223\345\205\245url\345\210\260\346\270\262\346\237\223.md" diff --git a/content/posts/z-drafts/java/base/java_1.md b/content/posts/study/java/base/java_1.md similarity index 100% rename from content/posts/z-drafts/java/base/java_1.md rename to content/posts/study/java/base/java_1.md diff --git a/content/posts/z-drafts/java/base/java_10.md b/content/posts/study/java/base/java_10.md similarity index 100% rename from content/posts/z-drafts/java/base/java_10.md rename to content/posts/study/java/base/java_10.md diff --git a/content/posts/z-drafts/java/base/java_11.md b/content/posts/study/java/base/java_11.md similarity index 100% rename from content/posts/z-drafts/java/base/java_11.md rename to content/posts/study/java/base/java_11.md diff --git a/content/posts/z-drafts/java/base/java_12.md b/content/posts/study/java/base/java_12.md similarity index 100% rename from content/posts/z-drafts/java/base/java_12.md rename to content/posts/study/java/base/java_12.md diff --git a/content/posts/z-drafts/java/base/java_13.md b/content/posts/study/java/base/java_13.md similarity index 100% rename from content/posts/z-drafts/java/base/java_13.md rename to content/posts/study/java/base/java_13.md diff --git a/content/posts/z-drafts/java/base/java_14.md b/content/posts/study/java/base/java_14.md similarity index 100% rename from content/posts/z-drafts/java/base/java_14.md rename to content/posts/study/java/base/java_14.md diff --git a/content/posts/z-drafts/java/base/java_2.md b/content/posts/study/java/base/java_2.md similarity index 100% rename from content/posts/z-drafts/java/base/java_2.md rename to content/posts/study/java/base/java_2.md diff --git a/content/posts/z-drafts/java/base/java_3.md b/content/posts/study/java/base/java_3.md similarity index 100% rename from content/posts/z-drafts/java/base/java_3.md rename to content/posts/study/java/base/java_3.md diff --git a/content/posts/z-drafts/java/base/java_4.md b/content/posts/study/java/base/java_4.md similarity index 100% rename from content/posts/z-drafts/java/base/java_4.md rename to content/posts/study/java/base/java_4.md diff --git a/content/posts/z-drafts/java/base/java_5.md b/content/posts/study/java/base/java_5.md similarity index 100% rename from content/posts/z-drafts/java/base/java_5.md rename to content/posts/study/java/base/java_5.md diff --git a/content/posts/z-drafts/java/base/java_6.md b/content/posts/study/java/base/java_6.md similarity index 100% rename from content/posts/z-drafts/java/base/java_6.md rename to content/posts/study/java/base/java_6.md diff --git a/content/posts/z-drafts/java/base/java_7.md b/content/posts/study/java/base/java_7.md similarity index 100% rename from content/posts/z-drafts/java/base/java_7.md rename to content/posts/study/java/base/java_7.md diff --git a/content/posts/z-drafts/java/base/java_8.md b/content/posts/study/java/base/java_8.md similarity index 100% rename from content/posts/z-drafts/java/base/java_8.md rename to content/posts/study/java/base/java_8.md diff --git a/content/posts/z-drafts/java/base/java_9.md b/content/posts/study/java/base/java_9.md similarity index 100% rename from content/posts/z-drafts/java/base/java_9.md rename to content/posts/study/java/base/java_9.md diff --git a/content/posts/z-drafts/java/mybatis/image-1.png b/content/posts/study/java/mybatis/image-1.png similarity index 100% rename from content/posts/z-drafts/java/mybatis/image-1.png rename to content/posts/study/java/mybatis/image-1.png diff --git a/content/posts/z-drafts/java/mybatis/image-2.png b/content/posts/study/java/mybatis/image-2.png similarity index 100% rename from content/posts/z-drafts/java/mybatis/image-2.png rename to content/posts/study/java/mybatis/image-2.png diff --git a/content/posts/z-drafts/java/mybatis/image.png b/content/posts/study/java/mybatis/image.png similarity index 100% rename from content/posts/z-drafts/java/mybatis/image.png rename to content/posts/study/java/mybatis/image.png diff --git a/content/posts/z-drafts/java/mybatis/mybatis.md b/content/posts/study/java/mybatis/mybatis.md similarity index 100% rename from content/posts/z-drafts/java/mybatis/mybatis.md rename to content/posts/study/java/mybatis/mybatis.md diff --git a/content/posts/z-drafts/java/mybatis/mybatis_plus.md b/content/posts/study/java/mybatis/mybatis_plus.md similarity index 100% rename from content/posts/z-drafts/java/mybatis/mybatis_plus.md rename to content/posts/study/java/mybatis/mybatis_plus.md diff --git a/content/posts/z-drafts/java/spring/spring_1.md b/content/posts/study/java/spring/spring_1.md similarity index 100% rename from content/posts/z-drafts/java/spring/spring_1.md rename to content/posts/study/java/spring/spring_1.md diff --git a/content/posts/tool/lerna.md b/content/posts/study/lerna.md similarity index 100% rename from content/posts/tool/lerna.md rename to content/posts/study/lerna.md diff --git "a/content/posts/tool/linux\345\237\272\347\241\200.md" "b/content/posts/study/linux\345\237\272\347\241\200.md" similarity index 100% rename from "content/posts/tool/linux\345\237\272\347\241\200.md" rename to "content/posts/study/linux\345\237\272\347\241\200.md" diff --git a/content/posts/mysql/JDBC.md b/content/posts/study/mysql/JDBC.md similarity index 100% rename from content/posts/mysql/JDBC.md rename to content/posts/study/mysql/JDBC.md diff --git a/content/posts/mysql/mysql_1.md b/content/posts/study/mysql/mysql_1.md similarity index 100% rename from content/posts/mysql/mysql_1.md rename to content/posts/study/mysql/mysql_1.md diff --git a/content/posts/mysql/mysql_2.md b/content/posts/study/mysql/mysql_2.md similarity index 100% rename from content/posts/mysql/mysql_2.md rename to content/posts/study/mysql/mysql_2.md diff --git a/content/posts/mysql/mysql_3.md b/content/posts/study/mysql/mysql_3.md similarity index 100% rename from content/posts/mysql/mysql_3.md rename to content/posts/study/mysql/mysql_3.md diff --git "a/content/posts/node/koa\346\264\213\350\221\261\346\250\241\345\236\213.md" "b/content/posts/study/node/koa\346\264\213\350\221\261\346\250\241\345\236\213.md" similarity index 100% rename from "content/posts/node/koa\346\264\213\350\221\261\346\250\241\345\236\213.md" rename to "content/posts/study/node/koa\346\264\213\350\221\261\346\250\241\345\236\213.md" diff --git "a/content/posts/node/node\345\237\272\347\241\200.md" "b/content/posts/study/node/node\345\237\272\347\241\200.md" similarity index 100% rename from "content/posts/node/node\345\237\272\347\241\200.md" rename to "content/posts/study/node/node\345\237\272\347\241\200.md" diff --git "a/content/posts/node/node\347\232\204\347\211\271\347\202\271.md" "b/content/posts/study/node/node\347\232\204\347\211\271\347\202\271.md" similarity index 100% rename from "content/posts/node/node\347\232\204\347\211\271\347\202\271.md" rename to "content/posts/study/node/node\347\232\204\347\211\271\347\202\271.md" diff --git a/content/posts/node/small_node/index.js b/content/posts/study/node/small_node/index.js similarity index 100% rename from content/posts/node/small_node/index.js rename to content/posts/study/node/small_node/index.js diff --git a/content/posts/node/small_node/requestHandler.js b/content/posts/study/node/small_node/requestHandler.js similarity index 100% rename from content/posts/node/small_node/requestHandler.js rename to content/posts/study/node/small_node/requestHandler.js diff --git a/content/posts/node/small_node/route.js b/content/posts/study/node/small_node/route.js similarity index 100% rename from content/posts/node/small_node/route.js rename to content/posts/study/node/small_node/route.js diff --git a/content/posts/node/small_node/server.js b/content/posts/study/node/small_node/server.js similarity index 100% rename from content/posts/node/small_node/server.js rename to content/posts/study/node/small_node/server.js diff --git a/content/posts/tool/rollup.md b/content/posts/study/rollup.md similarity index 100% rename from content/posts/tool/rollup.md rename to content/posts/study/rollup.md diff --git "a/content/posts/tool/shell\345\237\272\347\241\200.md" "b/content/posts/study/shell\345\237\272\347\241\200.md" similarity index 100% rename from "content/posts/tool/shell\345\237\272\347\241\200.md" rename to "content/posts/study/shell\345\237\272\347\241\200.md" diff --git "a/content/posts/tool/\345\274\200\345\217\221\344\270\200\344\270\252\345\221\275\344\273\244\350\241\214\345\267\245\345\205\267.md" "b/content/posts/study/\345\274\200\345\217\221\344\270\200\344\270\252\345\221\275\344\273\244\350\241\214\345\267\245\345\205\267.md" similarity index 100% rename from "content/posts/tool/\345\274\200\345\217\221\344\270\200\344\270\252\345\221\275\344\273\244\350\241\214\345\267\245\345\205\267.md" rename to "content/posts/study/\345\274\200\345\217\221\344\270\200\344\270\252\345\221\275\344\273\244\350\241\214\345\267\245\345\205\267.md" diff --git "a/content/posts/tool/git\350\207\252\347\224\250\346\211\213\345\206\214.md" "b/content/posts/tool/git\350\207\252\347\224\250\346\211\213\345\206\214.md" deleted file mode 100644 index 944f03e..0000000 --- "a/content/posts/tool/git\350\207\252\347\224\250\346\211\213\345\206\214.md" +++ /dev/null @@ -1,204 +0,0 @@ ---- -title: 'Git自用手册' -date: 2022-09-19T20:36:01+08:00 -tags: [git] -categories: [git] ---- - -**本文基于 git version 2.32.0** - ---- - -我知道有很多人在使用 SourceTree 之类的图形界面进行版本管理,但是从入行就习惯使用命令行和喜欢简约风的我还是喜欢在 terminal 内敲命令来进行 git 的相关操作,本文把这几年来常用的命令和经验分享一下。 - -鉴于是老生常谈的东西了,分为老手和新手两块。 - -## 老手命令 - -换电脑或者重做系统后,需要重新配置 git 命令别名,帮助简化命令(复制进 terminal 执行一下即可)。 - -```sh -# 普通流程 -git config --global alias.g git -# 只 clone 对应分支, g cloneb [br] [url], 对于 react 之类的大仓库,就很舒服~ -git config --global alias.cloneb 'clone --single-branch --branch' -git config --global alias.ad 'add -A' -git config --global alias.cm 'commit -m' -git config --global alias.ps push -git config --global alias.pso 'push origin' -git config --global alias.pl pull -git config --global alias.plo 'pull origin' -# 修改最后一次commit(会变更commitId) -git config --global alias.cam 'commit --amend -m' -# 追加修改,不加新commit -git config --global alias.can 'commit --amend --no-edit' -# 任意commit删/改 git ri cmid -git config --global alias.ri 'rebase -i' - -# 分支相关 -git config --global alias.br branch -git config --global alias.rn 'branch --move' # g rn oldname newname -git config --global alias.ck checkout # 常用命令 g ck -, 快速返回上一个分支 -git config --global alias.cb 'checkout -b' -git config --global alias.cp cherry-pick # g cp [commit/brname] 如果是brname则是把该分支最新commit合并 -# cherry-pick 可以与 reflog (查看HEAD指针的行走轨迹,包括因为reset被移出的commit) 配合,来找回被删除的 commit -git config --global alias.db 'branch -d' -git config --global alias.fdb 'branch -D' # 强制删除 -# 删除远程 g drb brname; 也可以推送一个空本地分支: g po :brname -git config --global alias.drb 'push origin --delete' - -# tag 相关 g tag [tname] -# 推送某个 tag: g po [tag] -git config --global alias.psot 'push origin --tags' -git config --global alias.dt 'tag -d' -git config --global alias.drt 'push origin --delete' # 也可以推送空tag g po :refs/tags/[version] - -git config --global alias.st status -git config --global alias.ss 'status -s' - -# 查看配置 -git config --global alias.cl 'config --list' -git config --global alias.cgl 'config --global --list' -git config --global alias.cll 'config --local --list' - -# log 美化 -git config --global alias.lg "log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit" -# 根据 commit 内容查找 commit -git config --global alias.find "log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --grep" -# 根据 commit 用户查找 commit -git config --global alias.findby "log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --author" - -# 下面两个命令倒是不常用,一般用 vscode 里的可视化操作 -git config --global alias.res restore -git config --global alias.rss 'restore --staged' -``` - -命令简化完后,需要配置下个人信息,我个人习惯是公司的项目都单独配置,全局给自己用。 - -```sh -# 全局配置 -git config --global user.name 'yourname' -git config --global user.email 'yourmail@163.com' - -# 单个项目配置 (cd到根目录) -git config user.name 'name' -git config user.email 'mail' -``` - -其它的一些实用命令: - -```sh -# 临时将工作区文件的修改保存至堆栈中 (常用于开发到一半要去改个bug) -git stash -# 将之前保存至堆栈中的文件取出来 -git stash pop - - -# HEAD 指针回退某个版本并基于那个版本修改bug -git checkout [commit] # HEAD 将处于 detached (游离) 状态 g st 可查看 -git checkout [current brname] # 当希望HEAD回到分支最初状态,这样即可 -# 一般可以用 checkout 回退版本,查看历史代码,测试 bug 在哪, -# 如果checkout的commit下修改了bug,提交了commit,签回分支末端时,会提示要不要建一个新分支 -# 这时候可以新建一个临时分支,然后你本地自己的开发主分支去合并它,合并完后删除临时分支 - -# 对某次 commit 做反向操作, 生成新的 commit, 常用来撤销中间的某一次提交 -git revert [commit] - -# rebase 用来变基合并的作用可能没有 rebase -i 使用的频繁 -# 执行下面的命令就能对 commit 进行一系列操作了 -# 常用的如 编辑,合并, 删除commit等 -git rebase -i [HEAD~3] - -# 把分支指针指向对应的commit,移除之后的提交 -git reset --hard [commit] # 重置暂存区和工作区 -git reset --soft [commit] # 保持暂存区和工作区不变 -git reset --mixed [commit] # 重置暂存区,工作区不变,是reset的默认方式 -``` - -上面的命令基本是够用了,不过 git 2.23 后有一些新命令: - -```sh -# switch 和 restore 都是来帮 checkout 分担压力的 -git switch [branchname] -git switch -c [branchname] # -c 表示创建 - -git restore [filename] -git restore --staged [filename] -``` - -> 注意:reflog 查看的是本地历史,在别的电脑上是看不见的,同理如果电脑坏了,那么也回不到未来了...另外,git reflog 不会永远保持,Git 会定期清理那些 “用不到的” 对象,不要指望几个月前的提交还一直在那里。 - -### 处理 fatal: refusing to merge unrelated histories - -```sh -g plo develop --allow-unrelated-histories -``` - ---- - -## 新手概念 - -### 四态三区 - -git 目录下的所有文件一共有四种状态: - -- untracked (就是新增但是未 add 的文件) -- unmodified -- unstaged -- staged - -本地三个 git 分区: - -- 工作区:存放着`untracked`、`unmodified`、`unstaged`的文件 -- 暂存区:当工作区文件被`git add` 后加入,文件状态为 `unstaged` -- 仓库区:当暂存区文件被`commit` 后加入 - -![](https://p3-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/017fb508b89d45a88c33383cdc4681eb~tplv-k3u1fbpfcp-zoom-1.image) - -### 分支 - -分支是很重要的一个概念,其实就是一个快照,创建的分支名只不过是指针而已,每一次提交就是指针往前移动。 - -HEAD 是特殊的分支指针,指向的是当前所在分支。这里得说一下 HEAD^n 与 HEAD~n: - -长话短说: - -- HEAD^^^ 等价于 HEAD~3 表示父父父提交 -- HEAD^3 表示的是父提交的第三个提交,即合并进来的其他提交 - -## 提交规范 - -通过 `husky` + `lint-staged` 配合来进行约束,详细配置根据项目来设定。 - -### 解决 vscode git log 中文字符乱码 - -```yml -#.gitconfig -[gui] - encoding = utf-8 - # 代码库统一使用utf-8 -[i18n] - commitencoding = utf-8 - # log编码 -[svn] - pathnameencoding = utf-8 - # 支持中文路径 -[core] - quotepath = false - # status引用路径不再是八进制(反过来说就是允许显示中文了) - -# 解决 vscode terminal git log 中文乱码 -export LC_ALL=en_US.UTF-8 -export LANG=en_US.UTF-8 -export LESSHARESET=utf-8 -``` - -### 补充 - -- [Git Tools - Submodules](https://git-scm.com/book/en/v2/Git-Tools-Submodules) -- [Git submodule 子模块的管理和使用](https://www.jianshu.com/p/9000cd49822c) - -## 参考 - -- [Pro Git 2nd Edition](https://git-scm.com) -- [“纸上谈兵”之 Git 原理](https://mp.weixin.qq.com/s/FSBEM2GqhpVJ6yw9FkxnGA) diff --git "a/content/posts/tool/mac\344\270\212bash\345\222\214zsh.md" "b/content/posts/z-drafts/mac\344\270\212bash\345\222\214zsh.md" similarity index 99% rename from "content/posts/tool/mac\344\270\212bash\345\222\214zsh.md" rename to "content/posts/z-drafts/mac\344\270\212bash\345\222\214zsh.md" index 55d7da8..1020495 100644 --- "a/content/posts/tool/mac\344\270\212bash\345\222\214zsh.md" +++ "b/content/posts/z-drafts/mac\344\270\212bash\345\222\214zsh.md" @@ -2,6 +2,7 @@ title: 'Mac上bash/zsh' date: 2022-11-25T10:27:55+08:00 tags: [mac, shell] +draft: true --- ## 基本概念 diff --git a/public/categories/bug/index.xml b/public/categories/bug/index.xml index e5e05e3..a07cf4c 100644 --- a/public/categories/bug/index.xml +++ b/public/categories/bug/index.xml @@ -10,7 +10,7 @@ Tue, 10 Oct 2023 23:40:56 +0800 EricYuan http://localhost:1313/%E6%9C%89%E8%B6%A3%E7%9A%84bug/ -
-
-