GitHub

merge

2024-02-27

merge 是 [[Git]] 分支合并命令,用于将一个分支的提交合并到另一个分支。

语法

Terminal window
git merge <branch_name>
  • --abort:终止合并;
  • --no-edit:合并时,不编辑合并信息;
  • --no-ff:合并时,创建一个 merge commit 信息,并保留分支 commit 信息;
  • --squash:合并时,创建一个新的 commit 信息,删除分支 commit 信息;
  • --ff

使用

配置合并策略

Terminal window
# 启用合并策略
git config merge.ours.driver true

需要配合 .gitattributes 文件使用,比如不希望合并 pyproject.tomluv.lock文件:

Terminal window
pyproject.toml merge=ours
uv.lock merge=ours