Skip to content

Commit

Permalink
doc: add sections about 'branch squash', 'branch edit' (#565)
Browse files Browse the repository at this point in the history
  • Loading branch information
abhinav authored Feb 5, 2025
1 parent bffa35c commit 41d1b87
Showing 1 changed file with 58 additions and 6 deletions.
64 changes: 58 additions & 6 deletions doc/src/guide/branch.md
Original file line number Diff line number Diff line change
Expand Up @@ -273,19 +273,17 @@ text "gs upstack restack" mono with w at last.e

### Automatic restacking

git-spice provides a handful of convenience commands
for common commit-related tasks
that will automatically restack upstack branches for you:
git-spice provides several convenience commands
that run common Git operations and automatically restack upstack branches.

These include but are not limited to:

- $$gs commit create$$ (or $$gs commit create|gs cc$$)
commits changes to the current branch and restacks upstack branches
- $$gs commit amend$$ (or $$gs commit amend|gs ca$$)
amends the last commit and restacks upstack branches
- $$gs commit split$$ (or $$gs commit split|gs csp$$)
interactively splits the last commit into two and restacks upstack branches
- $$gs branch edit$$ (or $$gs branch edit|gs be$$)
opens an interactive rebase of the commits in the current branch
and restacks upstack branches after the rebase completes successfully

For example, the interaction above can be shortened to:

Expand All @@ -296,6 +294,60 @@ For example, the interaction above can be shortened to:
{green}${reset} gs commit create {gray}# or gs cc{reset}
```

### Editing commits in a branch

The $$gs branch edit$$ command starts a `git rebase --interactive`
for the commits in the current branch.

```freeze language="terminal" float="right"
{green}${reset} gs branch edit
```

```
pick c0d0855d feat: Add support for things
pick 78c047c5 doc: Document something
pick 4dbf01a5 fix: Fix a thing that was broken
```

Use the usual Git rebase commands to edit, reorder, squash, or split commits.

After the rebase operation completes successfully,
upstack branches will be restacked on top of the current branch.

#### Handling rebase interruptions

```freeze language="terminal" float="right"
{green}${reset} gs rebase continue
{green}${reset} gs rebase abort
```

If a rebase operation is interrupted due to a conflict,
or because an `edit` or `break` instruction was used in the rebase script,
git-spice will pause execution and let you resolve the issue.
You may then:

- Resolve the conflict, make any planned changes,
and run $$gs rebase continue$$ (`gs rbc` for short)
to let git-spice continue the rest of the operation; or
- Run $$gs rebase abort$$ (`gs rba` for short) to abort the operation
and go back to the state before the rebase started.

### Squashing commits in a branch

<!-- gs:version unreleased -->

```freeze language="terminal" float="right"
{green}${reset} gs branch squash
```

$$gs branch squash$$ will squash all commits in the current branch
and open an editor to let you write a commit message for the squashed commit.
Use the `-m`/`--message` flag to provide a message without opening an editor.

If you want to squash only a subset of commits in the branch,
use $$gs branch edit$$ and add `squash` or `fixup` commands.


## Inserting into the stack

By default, $$gs branch create$$ creates a branch
Expand Down

0 comments on commit 41d1b87

Please sign in to comment.