Forrest logo
back to the git tool

git-squash:tldr:37bb1

git-squash: Squash the `n` latest commits and commit with a message.
$ git squash HEAD~${n} "${message}"
try on your machine

This command is used in Git to combine multiple commits into a single commit (or "squash" them).

Here's a breakdown of each part of the command:

  • git squash: This is not a built-in Git command, so it is likely a custom script or function defined in your Git configuration. It performs the actual squash operation.

  • HEAD~${n}: This refers to the parent commit(s) that will be included in the squash. The ~ symbol followed by ${n} indicates the number of commits you want to squash. HEAD~1 means the immediate previous commit, HEAD~2 means the previous two commits, and so on.

  • "${message}": This is the commit message for the resulting squashed commit. It should be enclosed in double quotes. Replace ${message} with the desired commit message.

So, when running this command, it will squash the specified number of previous commits (HEAD~${n}) into a single commit with the provided message ("${message}"). The exact behavior may depend on the git squash command implementation or additional configuration settings.

This explanation was created by an AI. In most cases those are correct. But please always be careful and never run a command you are not sure if it is safe.
back to the git tool