-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathstack.html
More file actions
422 lines (403 loc) · 15 KB
/
stack.html
File metadata and controls
422 lines (403 loc) · 15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Stack vs Branch Mode - Git Navigator</title>
<meta
name="description"
content="Understand stack mode vs branch mode in Git Navigator"
/>
<link rel="icon" href="static/icon.png" type="image/png" />
<link rel="stylesheet" href="static/site.css" />
</head>
<body class="page-stack">
<nav class="site-nav">
<div class="container nav-inner">
<a class="nav-brand" href="index.html">Git Navigator</a>
<div class="nav-links">
<a href="stack.html">Branch vs Stack mode</a>
<a href="stack_reviewer.html">Stack Reviewer</a>
</div>
</div>
</nav>
<header>
<div class="container hero">
<h1>Branch mode vs Stack mode</h1>
<p>
Git Navigator can treat your recent work as <strong>independent branches</strong>
or as a <strong>stack</strong> of commits. The difference matters when you edit
history. This page explains and compare how both options work.
</p>
<p><a href="index.html">Back to the main page</a></p>
</div>
</header>
<section>
<div class="container grid">
<div class="card">
<h2>Branch mode</h2>
<p>
Think of each branch as its own lane. When you change a commit, Git Navigator
updates only the branch you are working on, and keeps the graph compact.
</p>
<pre class="diagram">main A -> B -> C -> D
\
feature E -> F -> G (feature tip)
amend F (branch mode):
main A -> B -> C -> D
\
feature E -> F -> G (feature tip)
\
F' (detached)</pre>
<p>Only the branch tip stays at G. The amended commit F' is not on the branch.</p>
<ul>
<li>Good when branches are shared or long-lived.</li>
<li>Changes stay local to the branch you touched.</li>
<li>Safer if you are not sure who else uses the commits.</li>
<li>Lower risk of surprising teammates or CI.</li>
<li>Less likely to require force-pushes on shared branches.</li>
</ul>
</div>
<div class="card">
<h2>Stack mode</h2>
<p>
Think of your recent work as a stack of commits sitting on top of a base
branch (usually <strong>main</strong>). If you edit one commit, everything above it
in the stack is updated too, and the graph stays fully expanded.
</p>
<pre class="diagram">main A -> B -> C -> D
\
feature E -> F -> G (feature tip)
amend F (stack):
main A -> B -> C -> D
\
feature E -> F' -> G' (feature tip)</pre>
<p>G is rebased onto F' to create G', so the chain stays connected.</p>
<ul>
<li>Great for a series of small, dependent changes.</li>
<li>Keeps your stack consistent after reword, squash, or reorder.</li>
<li>Makes it easier to clean up history before sharing.</li>
</ul>
</div>
</div>
</section>
<section>
<div class="container">
<h2 class="section-title">Visual comparisons</h2>
<div class="grid">
<div class="card">
<h3>Drag-and-drop Rebase</h3>
<figure>
<div class="comparison">
<div class="comparison-item">
<span>Branch mode</span>
<div class="media-frame">
<video src="static/rebase-branch.mp4" autoplay muted loop playsinline data-zoom></video>
</div>
<figcaption>On branch mode, you drag the tip of a branch to rebase the branch and it's parent commits onto the new location. (Git automatically calculates the merge base.)</figcaption>
</div>
<div class="comparison-item">
<span>Stack mode</span>
<div class="media-frame">
<video src="static/rebase-stack.mp4" autoplay muted loop playsinline data-zoom></video>
</div>
<figcaption>On stack mode, you drag the base you want to rebase all of it's children and the entire descendant tree onto the new location. (All branch refs are updated with the rebase.)</figcaption>
</div>
</div>
</figure>
</div>
<div class="card">
<h3>Amend</h3>
<figure>
<div class="comparison">
<div class="comparison-item">
<span>Branch mode</span>
<div class="media-frame">
<video src="static/amend-branch.mp4" autoplay muted loop playsinline data-zoom></video>
</div>
<figcaption>Amending on branch mode creates a new branching commit</figcaption>
</div>
<div class="comparison-item">
<span>Stack mode</span>
<div class="media-frame">
<video src="static/amend-stack.mp4" autoplay muted loop playsinline data-zoom></video>
</div>
<figcaption>Amending on stack mode automatically rebases the rest of the stack onto the new change</figcaption>
</div>
</div>
</figure>
</div>
<div class="card">
<h3>Push</h3>
<figure>
<div class="comparison">
<div class="comparison-item">
<span>Branch mode</span>
<div class="media-frame">
<video src="static/push-branch.mp4" autoplay muted loop playsinline data-zoom></video>
</div>
<figcaption>Pushing on branch mode pushes the selected branch to remote</figcaption>
</div>
<div class="comparison-item">
<span>Stack mode</span>
<div class="media-frame">
<video src="static/push-stack.mp4" autoplay muted loop playsinline data-zoom></video>
</div>
<figcaption>Pushing on stack mode requires each commit on the stack to be a named branch before it can be pushed.</figcaption>
</div>
</div>
</figure>
</div>
<div class="card">
<h3>Cherrypick</h3>
<figure>
<div class="comparison">
<div class="comparison-item">
<span>Branch mode</span>
<div class="media-frame">
<video src="static/cherrypick.mp4" autoplay muted loop playsinline data-zoom></video>
</div>
<figcaption>Cherrypicking on branch mode cherrypicks the selected commit(s) to the target branch</figcaption>
</div>
<div class="comparison-item">
<span>Stack mode</span>
<figcaption>Cherrypick is unsupported on stack mode</figcaption>
</div>
</div>
</figure>
</div>
<div class="card">
<h3>Graph View</h3>
<figure>
<div class="comparison">
<div class="comparison-item">
<span>Branch mode</span>
<div class="media-frame">
<img
src="static/branch-graph.png"
alt="Branch mode compact graph view"
data-zoom
/>
</div>
<figcaption>Compact graph view</figcaption>
</div>
<div class="comparison-item">
<span>Stack mode</span>
<div class="media-frame">
<img src="static/stack-graph.png" alt="Stack mode full graph view" data-zoom />
</div>
<figcaption>Full graph with stack highlights</figcaption>
</div>
</div>
</figure>
</div>
</div>
</div>
</section>
<section>
<div class="container">
<h2 class="section-title">What actually changes when you edit a commit</h2>
<div class="grid">
<div class="card">
<h3>Branch mode</h3>
<p>
Only the branch tip you are on is rewritten. Other branches that happen
to include that commit are left alone.
</p>
</div>
<div class="card">
<h3>Stack mode</h3>
<p>
Git Navigator rewrites the commit and then updates any descendant
branches so they continue to point to the rewritten history.
</p>
</div>
</div>
</div>
</section>
<section>
<div class="container">
<h2 class="section-title">How to choose</h2>
<div class="card">
<p>
Stack workflows usually review commits one by one, so going back to amend an
earlier commit is normal. Branch-mode workflows usually review the branch as a
whole, so you typically add new commits instead of rewriting old ones.
</p>
<ul class="tips">
<li>Use <strong>branch mode</strong> if you are working on a shared or long-lived branch.</li>
<li>Use <strong>stack</strong> if you are building a short sequence of commits that depend on each other.</li>
<li>If you plan to rewrite history often (amend, squash, reorder), stack mode is smoother.</li>
<li>If you are unsure, start with branch mode. You can switch later.</li>
</ul>
</div>
</div>
</section>
<section>
<div class="container grid">
<div class="card">
<h2>How Git Navigator uses stack mode</h2>
<p>
Stack mode is stored per repository. Git Navigator uses a base reference
(by default, your default branch) and treats commits from that base to your
current work as one stack.
</p>
<p>
When you amend, rebase, or squash in stack mode, Git Navigator updates the
rest of the stack so everything stays connected and consistent.
</p>
</div>
<div class="card">
<h2>If you are new to Git</h2>
<p>
You do not have to pick a mode permanently. The safest mental model is:
branch mode is "change only what I can see," and stack is "change this and
everything built on top of it."
</p>
<p>
If you are still unsure, ask a teammate which workflow your project expects.
</p>
</div>
</div>
</section>
<section>
<div class="container">
<h2 class="section-title">[Advanced] Detailed comparison</h2>
<div class="card">
<h3>Graph visualization</h3>
<table>
<thead>
<tr>
<th>Aspect</th>
<th>Branch mode</th>
<th>Stack mode</th>
</tr>
</thead>
<tbody>
<tr>
<td>Commits shown</td>
<td>Branch tips only (collapsed view)</td>
<td>Full graph</td>
</tr>
<tr>
<td>Collapsed commits</td>
<td>Expandable placeholder (like default branch)</td>
<td>All visible</td>
</tr>
<tr>
<td>Visual highlighting</td>
<td>No stack highlighting</td>
<td>Stack commits highlighted, base marked</td>
</tr>
<tr>
<td>Stack badges</td>
<td>Hidden</td>
<td>Show stack depth badges</td>
</tr>
<tr>
<td>Default branch ancestors</td>
<td>Collapsed (placeholder)</td>
<td>Collapsed (placeholder)</td>
</tr>
</tbody>
</table>
</div>
<div class="card">
<h3>Drag-and-drop behavior</h3>
<table>
<thead>
<tr>
<th>Aspect</th>
<th>Branch mode</th>
<th>Stack mode</th>
</tr>
</thead>
<tbody>
<tr>
<td>What you drag</td>
<td>Branch tip</td>
<td>Base of a subtree</td>
</tr>
<tr>
<td>What moves</td>
<td>Single branch</td>
<td>Entire subtree</td>
</tr>
<tr>
<td>Preview shows</td>
<td>One branch rebasing</td>
<td>Subtree moving with all affected branches</td>
</tr>
</tbody>
</table>
</div>
<div class="card">
<h3>Operations</h3>
<table>
<thead>
<tr>
<th>Operation</th>
<th>Branch mode</th>
<th>Stack mode</th>
</tr>
</thead>
<tbody>
<tr>
<td>Amend</td>
<td>Current commit only</td>
<td>Updates the stack above it</td>
</tr>
<tr>
<td>Push</td>
<td>Single branch push</td>
<td>Multi-branch stack push</td>
</tr>
<tr>
<td>Squash</td>
<td>Current branch only</td>
<td>Squashes a stack and keeps it connected</td>
</tr>
<tr>
<td>Split</td>
<td>Only allowed on branch tips</td>
<td>Allowed on any stack commit</td>
</tr>
<tr>
<td>Rebase</td>
<td>One branch at a time</td>
<td>Moves the stack together</td>
</tr>
<tr>
<td>Conflict resolution</td>
<td>Same UI, standard rebase flow</td>
<td>Same UI, stack-aware rebase flow</td>
</tr>
</tbody>
</table>
</div>
</div>
</section>
<footer class="site-footer">
<div class="container footer-inner">
<a
class="footer-link"
href="https://github.com/binhonglee/git_navigator"
target="_blank"
rel="noreferrer"
>
GitHub
</a>
<a class="button secondary" href="mailto:binhong@binhong.me">Contact</a>
</div>
</footer>
<div class="overlay" id="media-overlay" aria-hidden="true">
<div class="overlay-content">
<button class="overlay-close" type="button" aria-label="Close media">
x
</button>
<div class="overlay-body"></div>
</div>
</div>
<script src="static/site.js"></script>
</body>
</html>