Skip to content

Commit 9648401

Browse files
committed
Suggest using git range-diff
I have found it to be very helpful when rebasing.
1 parent 9a676ee commit 9648401

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

src/git.md

+21
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,7 @@ there are no glaring errors.
217217
Once you're all done fixing the conflicts, you need to stage the files that had
218218
conflicts in them via `git add`. Afterwards, run `git rebase --continue` to let
219219
Git know that you've resolved the conflicts and it should finish the rebase.
220+
220221
Once the rebase has succeeded, you'll want to update the associated branch on
221222
your fork with `git push --force-with-lease`.
222223

@@ -263,6 +264,26 @@ You also may want to squash just the last few commits together, possibly
263264
because they only represent "fixups" and not real changes. For example,
264265
`git rebase --interactive HEAD~2` will allow you to edit the two commits only.
265266

267+
### `git range-diff`
268+
269+
After completing a complicated rebase, or even a relatively simple one, you may
270+
want to review the changes between your old branch and your new one. You can do
271+
that with the `git range-diff master @{u} HEAD` command, which can be very
272+
helpful when you had a complicated rebase and you want to make sure you changed
273+
the right things.
274+
275+
Unlike in regular Git diffs, you'll see a `-` or `+` next to another `-` or `+`
276+
in the range-diff output. The marker on the left indicates a change between the
277+
old branch and the new branch, and the marker on the right indicates a change
278+
you've committed. So, you can think of a range-diff as a "diff of diffs" since
279+
it shows you the differences between your old diff and your new diff.
280+
281+
`git range-diff` is a very useful command, but note that it can take some time
282+
to get used to its output format. You may also find Git's documentation on the
283+
command useful, especially [their "Examples" section][range-diff-example-docs].
284+
285+
[range-diff-example-docs]: https://git-scm.com/docs/git-range-diff#_examples
286+
266287
## No-Merge Policy
267288

268289
The rust-lang/rust repo uses what is known as a "rebase workflow." This means

0 commit comments

Comments
 (0)