git-stack2
v0.1.17
Published
A tool for managing stacked Git branches with powerful commands for navigation, rebasing, and atomic operations.
Readme
git-stack2
A tool for managing stacked Git branches with powerful commands for navigation, rebasing, and atomic operations.
Installation
npm install -g git-stack2Usage
Show current stack
git stackThis displays all branches in your current stack, with the current branch highlighted.
Navigate the stack
Move up one branch (toward the tip):
git stack upMove down one branch (toward the base):
git stack downJump to the top of the stack:
git stack topJump to the bottom of the stack:
git stack bottomModify commits in a stack
Amend the current commit and automatically rebase dependent branches:
git amend
# Pass any git commit --amend flags
git amend --no-edit
git amend -m "Updated commit message"Insert a new commit/branch and automatically rebase dependent branches:
git insert
# Pass any git commit flags
git insert -m "New feature"Sync with remote
Pull all topmost branches in the current stack with rebase:
git stack pullPush all branches in the current stack atomically:
git stack pushMove the entire stack
Move your entire stack onto a different base branch:
git stack move <branch>
# Example: move stack from main to develop
git stack move developHow it works
The tool identifies your git stack by:
- Finding all local branches in the repository
- Determining the default branch (main or master)
- Computing the merge-base of each branch with the default branch to narrow the scope of "relevant changes"
- Building a graph of parent-child relationships using
git log
This allows you to easily navigate through a stack of related feature branches. It's also easy to migrate from any existing git stack tool, since it doesn't store any state.
Example
If you have branches structured like:
main(base)feature-1(based on main)feature-2(based on feature-1)feature-3(based on feature-2)
When you're on feature-2, running git stack will show:
Current stack:
────────────────────────────────────────
feature-3
│
→ feature-2 (current)
│
feature-1
────────────────────────────────────────
Total branches in stack: 3You can then use git stack up to move to feature-3 or git stack down to move to feature-1.
