|
| 1 | +--- |
| 2 | +title: Moving Branches Between Stacks |
| 3 | +description: Learn how to reorganize your branches by moving them between different stacks |
| 4 | +--- |
| 5 | + |
| 6 | +## Overview |
| 7 | + |
| 8 | +GitButler allows you to move branches between stacks through a simple drag-and-drop interface. This is useful when you want to reorganize your work, change branch dependencies, or consolidate related branches into a single stack. |
| 9 | + |
| 10 | +## Moving a Branch to Another Stack |
| 11 | + |
| 12 | +You can move a branch from one stack to another by dragging it to a specific position in the target stack. |
| 13 | + |
| 14 | +### How to Move a Branch |
| 15 | + |
| 16 | +1. **Drag the branch header** - Click and hold on the branch header (the section displaying the branch name) |
| 17 | +2. **Drop on target location** - Drag it to the position where you want to insert it in another stack |
| 18 | + |
| 19 | +When you hover over a valid drop target during the drag operation, you'll see visual indicators showing where the branch will be placed. |
| 20 | + |
| 21 | +<video width="100%" controls muted> |
| 22 | + <source src="https://gitbutler-docs-images-public.s3.us-east-1.amazonaws.com/drag-branches.mp4" type="video/mp4" /> |
| 23 | + Your browser does not support the video tag. |
| 24 | +</video> |
| 25 | + |
| 26 | + |
| 27 | +### Drop Zones |
| 28 | + |
| 29 | +There are two types of drop zones when moving branches: |
| 30 | + |
| 31 | +- **Between branches** - Drop the branch between two existing branches in a stack to insert it at that position |
| 32 | +- **Top of stack** - Drop at the top of a stack to make the moved branch the first branch |
| 33 | + |
| 34 | +The drop zones appear as horizontal lines with visual feedback when you hover over them during a drag operation. |
| 35 | + |
| 36 | +## Creating a New Stack (Tearing Off) |
| 37 | + |
| 38 | +You can also separate a branch from its current stack and create a new independent stack for it. This is called "tearing off" a branch. |
| 39 | + |
| 40 | +### How to Tear Off a Branch |
| 41 | + |
| 42 | +1. **Drag the branch header** - Click and hold on the branch header you want to separate |
| 43 | +2. **Drop outside the stacks area** - Drag it to the designated dropzone outside of the existing stacks |
| 44 | + |
| 45 | +This creates a new standalone stack containing just that branch. |
| 46 | + |
| 47 | +<video width="100%" controls muted> |
| 48 | + <source src="https://gitbutler-docs-images-public.s3.us-east-1.amazonaws.com/tearoff-stack.mp4" type="video/mp4" /> |
| 49 | + Your browser does not support the video tag. |
| 50 | +</video> |
| 51 | + |
| 52 | +## Important Considerations |
| 53 | + |
| 54 | +### Branch Requirements |
| 55 | + |
| 56 | +Not all branches can be moved. A branch must meet these conditions to be movable: |
| 57 | + |
| 58 | +- **No conflicts** - The branch must not have any merge conflicts |
| 59 | +- **Has commits** - The branch must contain at least one commit |
| 60 | +- **Different target stack** - You can only move branches to different stacks (not within the same stack) |
| 61 | + |
| 62 | +### What Happens During a Move |
| 63 | + |
| 64 | +When you move a branch: |
| 65 | + |
| 66 | +1. **Branch is extracted** - The branch and its commits are extracted from the source stack |
| 67 | +2. **Rebasing occurs** - The branch is rebased onto the new base in the target stack |
| 68 | +3. **References updated** - Git references are updated to reflect the new structure |
| 69 | +4. **Stack cleanup** - If the moved branch was the last one in its stack, that stack is deleted |
| 70 | + |
| 71 | +### Pull Request Updates |
| 72 | + |
| 73 | +If you're using GitHub integration and the branch has an associated pull request: |
| 74 | + |
| 75 | +- **PR descriptions are automatically updated** - The PR base and description are updated to reflect the new stack structure |
| 76 | +- **Stack PRs are synchronized** - All PRs in both the source and target stacks have their descriptions updated to maintain proper stacking information |
| 77 | + |
| 78 | + |
| 79 | +## Related Features |
| 80 | + |
| 81 | +- [Stacked Branches](/docs/features/branch-management/stacked-branches) - Learn about working with stacked branches |
| 82 | +- [Branch Lanes](/docs/features/branch-management/branch-lanes) - Understand the branch lane interface |
| 83 | +- [Virtual Branches](/docs/features/branch-management/virtual-branches) - Core concepts of GitButler's virtual branch system |
0 commit comments