# Autosquash
The `--autosquash` flag for `git rebase -i` automatically reorders and marks commits whose messages start with `fixup!` or `squash!` to be squashed into the matching commit.
## The trick
Setting `GIT_SEQUENCE_EDITOR=true` skips the interactive editor entirely — `true` is a Unix command that exits successfully, so it accepts the auto-arranged rebase plan as-is:
```bash
GIT_SEQUENCE_EDITOR=true git rebase -i --autosquash origin/master
```
This gives you a fully non-interactive autosquash rebase.
## Workflow
1. Make your main commit:
```bash
git commit -m "Add login page"
```
2. Later, fix something in that commit using `--fixup`. You can target by message, hash, or relative ref:
```bash
git commit --fixup="Add login page"
git commit --fixup=a1b2c3d
git commit --fixup=HEAD~2
```
3. When ready, squash them together without opening the editor:
```bash
GIT_SEQUENCE_EDITOR=true git rebase -i --autosquash origin/master
```
## See also
- [[Interactive Rebase]]
- [[Autostash]]