# git merge --no-ff和git merge --ff-only区别

**URL:** <https://forum.beginner.center/t/topic/2949>\
**Category:** 🛠工具与编程\
**Tags:** git\
**Created:** [2026 年7 月 23 日 03:24 UTC](https://forum.beginner.center/t/topic/2949 "2026-07-23T03:24:05Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

作者： ![doggie](https://forum.beginner.center/user_avatar/forum.beginner.center/doggie/32/550_2.png) [@doggie](https://forum.beginner.center/u/doggie)\
发布日期： [2026 年7 月 23 日 03:24 UTC](https://forum.beginner.center/t/topic/2949/1 "2026-07-23T03:24:06Z")

</div>

# `--ff-only` 不创建merge提交

```bash
git merge --ff-only codex/new-branch

```

仅允许快进合并：直接移动当前分支指针，不创建合并提交。

```plaintext
A──B──C

```

如果两个分支已经分叉，合并会失败。

适合：保持线性的提交历史。

# `--no-ff` 创建merge提交

```bash
git merge --no-ff codex/new-branch

```

即使可以快进，也会创建一个新的合并提交。

```plaintext
A──B────M
    \ /
     C

```

适合：保留功能分支的完整合并记录。

### 总结

- `--ff-only`：能快进就合并，否则停止，不创建合并提交。
- `--no-ff`：通过合并提交保留分支边界。
