diff --git a/src/git.md b/src/git.md index e533426cf..aae543312 100644 --- a/src/git.md +++ b/src/git.md @@ -217,6 +217,7 @@ there are no glaring errors. Once you're all done fixing the conflicts, you need to stage the files that had conflicts in them via `git add`. Afterwards, run `git rebase --continue` to let Git know that you've resolved the conflicts and it should finish the rebase. + Once the rebase has succeeded, you'll want to update the associated branch on your fork with `git push --force-with-lease`. @@ -263,6 +264,26 @@ You also may want to squash just the last few commits together, possibly because they only represent "fixups" and not real changes. For example, `git rebase --interactive HEAD~2` will allow you to edit the two commits only. +### `git range-diff` + +After completing a complicated rebase, or even a relatively simple one, you may +want to review the changes between your old branch and your new one. You can do +that with the `git range-diff master @{u} HEAD` command, which can be very +helpful when you had a complicated rebase and you want to make sure you changed +the right things. + +Unlike in regular Git diffs, you'll see a `-` or `+` next to another `-` or `+` +in the range-diff output. The marker on the left indicates a change between the +old branch and the new branch, and the marker on the right indicates a change +you've committed. So, you can think of a range-diff as a "diff of diffs" since +it shows you the differences between your old diff and your new diff. + +`git range-diff` is a very useful command, but note that it can take some time +to get used to its output format. You may also find Git's documentation on the +command useful, especially their ["Examples" section][range-diff-example-docs]. + +[range-diff-example-docs]: https://git-scm.com/docs/git-range-diff#_examples + ## No-Merge Policy The rust-lang/rust repo uses what is known as a "rebase workflow." This means