Skip to content

高级用法

子模块(Submodule)

bash
git submodule add <URL> <>  # 添加子模块
git submodule update --init    # 初始化子模块
git submodule update --remote  # 更新子模块到最新版本

交互式变基(Interactive Rebase)

bash
git rebase -i HEAD~3          # 交互式修改最近 3 个提交
# 在编辑器中选择操作:pick、reword、edit、squash、fixup

合并冲突解决

bash
git merge <branch>            # 发生冲突时
git status                    # 查看冲突文件
# 手动编辑冲突文件
git add <已解决文>
git commit                    # 完成合并