A tool for managing stacked Git branches with powerful commands for navigation, rebasing, and atomic operations.
npm install git-stack2A tool for managing stacked Git branches with powerful commands for navigation, rebasing, and atomic operations.
``bash`
npm install -g git-stack2
`bash`
git stack
This displays all branches in your current stack, with the current branch highlighted.
Move up one branch (toward the tip):
`bash`
git stack up
Move down one branch (toward the base):
`bash`
git stack down
Jump to the top of the stack:
`bash`
git stack top
Jump to the bottom of the stack:
`bash`
git stack bottom
Amend the current commit and automatically rebase dependent branches:
`bash`
git amendPass 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:
`bash`
git insertPass any git commit flags
git insert -m "New feature"
Pull all topmost branches in the current stack with rebase:
`bash`
git stack pull
Push all branches in the current stack atomically:
`bash`
git stack push
Move your entire stack onto a different base branch:
`bash`
git stack move Example: move stack from main to develop
git stack move develop
The tool identifies your git stack by:
1. Finding all local branches in the repository
2. Determining the default branch (main or master)
3. Computing the merge-base of each branch with the default branch to narrow the scope of "relevant changes"
4. 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.
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: 3
`
You can then use git stack up to move to feature-3 or git stack down to move to feature-1`.