← 返回命令列表

Linux command

git-squash 命令

文本

复制后可按需替换文件名、目录或参数。

常用示例

Squash branch into current

git squash [branch]

Squash with message

git squash [branch] "[message]"

Squash the last N commits

git squash HEAD~[5] "[message]"

Squash with concatenated commit messages

git squash --squash-msg [branch]

说明

git squash merges all commits from a specified branch or commit range into the current branch as a single squashed commit. Part of git-extras, it is useful for cleaning up feature branch history before merging into the main branch. When a commit ref from the current branch is given, the range from that ref to HEAD is squashed. If no commit message is provided and --squash-msg is not used, changes are staged but not committed.

参数

--squash-msg
Commit the squash result with the concatenated messages of all squashed commits. Cannot be used together with a commit message argument.

FAQ

What is the git-squash command used for?

git squash merges all commits from a specified branch or commit range into the current branch as a single squashed commit. Part of git-extras, it is useful for cleaning up feature branch history before merging into the main branch. When a commit ref from the current branch is given, the range from that ref to HEAD is squashed. If no commit message is provided and --squash-msg is not used, changes are staged but not committed.

How do I run a basic git-squash example?

Run `git squash [branch]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does --squash-msg do in git-squash?

Commit the squash result with the concatenated messages of all squashed commits. Cannot be used together with a commit message argument.