https://github.com/thomasbachem/git-edit
Easily edit Git commits via interactive rebase
https://github.com/thomasbachem/git-edit
command-line git rebase zsh
Last synced: about 1 month ago
JSON representation
Easily edit Git commits via interactive rebase
- Host: GitHub
- URL: https://github.com/thomasbachem/git-edit
- Owner: thomasbachem
- Created: 2025-07-07T03:08:29.000Z (11 months ago)
- Default Branch: main
- Last Pushed: 2025-08-10T18:49:58.000Z (10 months ago)
- Last Synced: 2025-10-12T06:32:09.698Z (8 months ago)
- Topics: command-line, git, rebase, zsh
- Language: Shell
- Homepage:
- Size: 76.2 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# git edit – Easily edit commits via interactive rebase
This Git subcommand script makes it easy to edit, modify, drop, or merge previous commits. It's essentially a more convenient wrapper around `git rebase --interactive`, with automatic stashing/unstashing and integrated merge conflict handling.
## Usage
```
git-edit [-m | --message]
git-edit [-d | --drop | -s | --squash] ...
MODES:
-e, --edit Edit (default mode)
-d, --drop Delete (drop) one or more s or ranges
-s, --squash Merge (fixup/squash) one or more s into the oldest one
-s , --squash Merge (fixup/squash) s into
– also assumed when multiple commits are supplied
FLAGS:
-m, --message Alter message after applying changes
```
*Tip:* Mode and flags can be given in any order.
## Usage Examples
### Editing
Open the given commit for manual editing, keeping its commit message (or add `-m` to also edit the message):
```
git edit 0123456789abcdef0123456789abcdef01234567
```
This will:
1. Stash any current local changes
2. Reset to the chosen commit
3. **Pause so you can make changes**
4. Amend the commit and continue the rebase (pausing if merge conflicts occur so you can resolve them)
5. Restore your stashed changes
### Merging
Merge multiple commits into the oldest one among them, keeping only the target commit's message (or add `-m` to also edit the message):
```
git edit 0123456789abcdef0123456789abcdef01234567 abcdef0123456789abcdef0123456789abcdef01
```
*Note:* You can also use ranges (e.g., `git edit HEAD~3..HEAD`).
This will:
1. Stash any current local changes
2. Determine the oldest of the provided commits, making it the target
3. **Merge the newer commits into it**
4. Continue the rebase (pausing if merge conflicts occur so you can resolve them)
5. Restore your stashed changes
## Screenshot

## Installation
Make the script available as a Git command by adding its folder to your `PATH`, e.g. by adding this line to `~/.zshrc`:
```
export PATH="$PATH:/your/path/to/git-edit"
```
## ⚠ Warning: History Rewriting
This script rewrites Git history from the chosen commit onward — changing the SHA-1 of that commit and all later commits.
- Safe if: Commits haven’t been pushed yet, or you’re the only developer
- Risky if: Others have based work on these commits (branches, forks, etc.)
If rewriting history, you’ll need to force-push (`git push --force`), which can disrupt collaborators.