# ===== CodeLab: git-submodule =====
# 以下代码片段按文章出现顺序拼接, 共 8 段

# ----- 片段 1 (bash) -----
git submodule add git@github.com:用户名/my-tools.git libs/my-tools

# ----- 片段 2 (bash) -----
cat .gitmodules
# [submodule "libs/my-tools"]
#     path = libs/my-tools
#     url = git@github.com:用户名/my-tools.git

# ----- 片段 3 (bash) -----
git clone git@github.com:用户名/项目.git
cd 项目
git submodule init
git submodule update
# 或者克隆时一步到位:
git clone --recursive git@github.com:用户名/项目.git

# ----- 片段 4 (bash) -----
cd libs/my-tools
git fetch
git checkout v1.2.0    # 或者 git pull 到最新
cd ../..
git add libs/my-tools
git commit -m "升级 my-tools 到 v1.2.0"

# ----- 片段 5 (bash) -----
git rm libs/my-tools
rm -rf .git/modules/libs/my-tools

# ----- 片段 6 (text) -----
# 编译产物
*.pyc
__pycache__/
dist/
# 本地配置
.env
config.local.json
# 临时文件
*.log

# ----- 片段 7 (bash) -----
git config --global alias.st status
git config --global alias.lg "log --oneline --graph --all"
git st
git lg

# ----- 片段 8 (bash) -----
git stash push -m "登录页改了一半"
git stash list
git stash pop
