Skip to content

Commit 4eaad9b

Browse files
committed
docs: improve README to fix arxanas#5
1 parent a60dbce commit 4eaad9b

File tree

2 files changed

+93
-16
lines changed

2 files changed

+93
-16
lines changed

README.md

Lines changed: 93 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,32 +3,109 @@
33
[![CI](https://github.com/arxanas/git-branchless/workflows/CI/badge.svg)](https://github.com/arxanas/git-branchless/actions?query=workflow%3ACI+branch%3Amaster)
44
[![crates.io](http://meritbadge.herokuapp.com/git-branchless)](https://crates.io/crates/git-branchless)
55

6-
## Demo
6+
`git-branchless` is a suite of tools to help you **visualize**, **navigate**, **manipulate**, and **repair** your commit history. It's based off of the branchless Mercurial workflows at large companies such as Google and Facebook.
77

8-
[See the demo at asciinema](https://asciinema.org/a/ZHdMDW9997wzctW1T7QsUFe9G):
8+
- [Demos](#demos)
9+
- [Repair](#repair)
10+
- [Visualize](#visualize)
11+
- [Navigate and manipulate](#navigate-and-manipulate)
12+
- [About](#about)
13+
- [Installation](#installation)
14+
- [Status](#status)
15+
16+
## Demos
17+
### Repair
18+
19+
Undo almost anything:
20+
21+
- Commits.
22+
- Amended commits.
23+
- Merges and rebases (e.g. if you resolved a conflict wrongly).
24+
- Checkouts.
25+
- Branch creations, updates, and deletions.
26+
27+
<p align="center">
28+
<a href="https://asciinema.org/a/2hRDqRZKyppzmDL3Dz8zRleNd" target="_blank"><img src="https://asciinema.org/a/2hRDqRZKyppzmDL3Dz8zRleNd.svg" /></a>
29+
</p>
30+
31+
<details>
32+
<summary>Why not <code>git reflog</code>?</summary>
33+
34+
`git reflog` is a tool to view the previous position of a single reference (like `HEAD`), which can be used to undo operations. But since it only tracks the position of a single reference, complicated operations like rebases can be tedious to reverse-engineer. `git undo` operates at a higher level of abstraction: the entire state of your repository.
35+
36+
`git reflog` also fundamentally can't be used to undo some rare operations, such as certain branch creations, updates, and deletions. [See the architecture document](https://github.com/arxanas/git-branchless/wiki/Architecture#comparison-with-the-reflog) for more details.
37+
38+
</details>
39+
40+
<details>
41+
<summary>What doesn't <code>git undo</code> handle?</summary>
42+
43+
`git undo` relies on features in recent versions of Git to work properly. See the [compatibility chart](https://github.com/arxanas/git-branchless/wiki/Installation#compatibility).
44+
45+
Currently, `git undo` can't undo the following. You can find the design document to handle some of these cases in [issue #10](https://github.com/arxanas/git-branchless/issues/10).
46+
47+
- "Uncommitting" a commit by undoing the commit and restoring its changes to the working copy.
48+
- In stock Git, this can be accomplished with `git reset --soft HEAD^` followed by `git restore .`.
49+
- This scenario would be better implemented with a custom `git uncommit` command instead. See [issue #3](https://github.com/arxanas/git-branchless/issues/3).
50+
- Undoing the staging or unstaging of files. This is tracked by issue #10 above.
51+
- Undoing back into the _middle_ of a conflict, such that `git status` shows a message like `path/to/file (both modified)`, so that you can resolve that specific conflict differently. This is tracked by issue #10 above.
52+
53+
Fundamentally, `git undo` is not intended to handle changes to untracked files.
54+
55+
</details>
56+
57+
<details>
58+
<summary>Comparison to other Git undo tools</summary>
59+
60+
- [`gitjk`](https://github.com/mapmeld/gitjk): Requires a shell alias. Only undoes most recent command. Only handles some Git operations (e.g. doesn't handle rebases).
61+
- [`git-extras/git-undo`](https://github.com/tj/git-extras/blob/master/man/git-undo.md): Only undoes commits at current `HEAD`.
62+
- [`git-annex undo`](https://git-annex.branchable.com/git-annex-undo/): Only undoes the most recent change to a given file or directory.
63+
- [`thefuck`](https://github.com/nvbn/thefuck): Only undoes historical shell commands. Only handles some Git operations (e.g. doesn't handle rebases).
64+
65+
</details>
66+
67+
### Visualize
68+
69+
Visualize your commit history with the smartlog (`git sl`):
70+
71+
<p align="center">
72+
<img src="media/git-sl.png" /></a>
73+
</p>
74+
75+
<details>
76+
<summary>Why not `git log --graph`?</summary>
77+
78+
`git log --graph` only shows commits which have branches attached with them. If you prefer to work without branches, then `git log --graph` won't work for you.
79+
80+
To support users who rewrite history extensively, `git sl` also points out commits which have been abandoned and need to be repaired (descendants of commits marked with `rewritten as abcd1234`). They can be automatically fixed up with `git restack`, or manually handled.
81+
82+
</details>
83+
84+
### Navigate and manipulate
85+
86+
Rewrite history without fear:
987

1088
<p align="center">
11-
<a href="https://asciinema.org/a/ZHdMDW9997wzctW1T7QsUFe9G" target="_blank"><img src="https://asciinema.org/a/ZHdMDW9997wzctW1T7QsUFe9G.svg" /></a>
89+
<a href="https://asciinema.org/a/3UVPMf0IpJaGdP6Kd6Zum4cq8" target="_blank"><img src="https://asciinema.org/a/3UVPMf0IpJaGdP6Kd6Zum4cq8.svg" /></a>
1290
</p>
1391

14-
## Why?
92+
<details>
93+
<summary>Why not `git rebase -i`?</summary>
94+
95+
Interactive rebasing with `git rebase -i` is fully supported, but it has a couple of shortcomings:
96+
97+
- `git rebase -i` can only repair linear series of commits, not trees. If you modify a commit with multiple children, then you have to be sure to rebase all of the other children commits appropriately.
98+
- You have to commit to a plan of action before starting the rebase. For some use-cases, it can be easier to operate on individual commits at a time, rather than an entire series of commits all at once.
1599

16-
Most Git workflows involve heavy use of branches to track commit work that is underway. However, branches require that you "name" every commit you're interested in tracking. If you spend a lot of time doing any of the following:
100+
When you use `git rebase -i` with `git-branchless`, you will be prompted to repair your history if you abandon any commits.
17101

18-
* Switching between work tasks.
19-
* Separating minor cleanups/refactorings into their own commits, for ease of
20-
reviewability.
21-
* Extensively rewriting local history before submitting code for review.
22-
* Performing speculative work which may not be ultimately committed.
23-
* Working on top of work that you or a collaborator produced, which is not
24-
yet checked in.
25-
* Losing track of `git stash`es you made previously.
102+
</details>
26103

27-
Then the branchless workflow may be for you instead.
104+
## About
28105

29-
The branchless workflow is designed for use at monorepo-scale, where the repository has a single main branch that all commits are applied to. It's based off the Mercurial workflows at large companies such as Google and Facebook. You can use it for smaller repositories as well, as long as you have a single main branch.
106+
The branchless workflow is designed for use in a repository with a **single main branch** that all commits are rebased onto. It improves developer velocity by encouraging fast and frequent commits, and helps developers operate on these commits fearlessly.
30107

31-
The branchless workflow is perfectly compatible with local branches if you choose to use them — they're just not necessary anymore.
108+
In the branchless workflow, the commits you're working on are inferred based on your activity, so you no longer need branches to keep track of them. Nonetheless, branches are sometimes convenient, and `git-branchless` fully supports them. If you prefer, you can continue to use your normal workflow and benefit from features like `git sl` or `git undo` without going entirely branchless.
32109

33110
## Installation
34111

media/git-sl.png

52.7 KB
Loading

0 commit comments

Comments
 (0)