Skip to main content

Git

全局设置

git config --global --edit
# 设置名字和邮箱
git config --global user.name "Mona Lisa"
git config --global user.email "[email protected]"

重命名 submodule

git mv oldNamePath newNamePath

如何删除 git submodule

To remove a submodule you need to:

  • Delete the relevant section from the .gitmodules file.
  • Stage the .gitmodules changes git add .gitmodules
  • Delete the relevant section from .git/config.
  • Run git rm --cached path_to_submodule (no trailing slash /).
  • Run rm -rf .git/modules/path_to_submodule (no trailing slash /).
  • Commit git commit -m "Removed submodule <name>"
  • Delete the now untracked submodule files rm -rf path_to_submodule

Git Alias

[alias]
st = status
stat = show --stat
ll = log --pretty=oneline --abbrev-commit --graph --decorate
lc = log --pretty=\"%h | %s | %an | %ci\" --abbrev-commit --graph --decorate

ps = push
fps = push --force
pu = pull


ff = log --follow
ffli = log --follow --pretty=\"%h | %s | %an | %ci\" --abbrev-commit --graph --decorate
fflr = log --follow --pretty=\"%h | %s | %an | %cr\" --abbrev-commit --graph --decorate

aa = add --all

d = diff
dc = diff --cached

ck = checkout
rs = reset
br = branch
cm = commit -m
ca = commit --amend
sh = show

cc = shortlog -s -n --all --no-merges

对 npm 依赖进行本地修改,并且保持这些修改

npm i patch-package
# or
yarn add patch-package postinstall-postinstall
  1. 首先修改 node_module 源码并保存
  2. 使用 npx patch-package [packageName] 生成 patch 文件
  3. (可选) 如果需要的话,可以使用 yarn patch-package next --create-issue 提交修改并生成 Github Issue
  4. package.json 文件增加
"scripts": {
"postinstall": "patch-package"
}

例子

问题

文件名太长

git config --system core.longpaths true
git config --system core.longpaths false