Skip to content

Commit 036e9ae

Browse files
docs: Don't make assumptions about remote default branch (#376)
Co-authored-by: Sindre T. Strøm <[email protected]>
1 parent fc998f9 commit 036e9ae

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

USAGE.md

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@ $ gh pr checkout {PR_ID}
1717
Now, run a symmetric diff against the base branch:
1818

1919
```vim
20-
:DiffviewOpen origin/main...HEAD --imply-local
20+
:DiffviewOpen origin/HEAD...HEAD --imply-local
2121
```
2222

2323
The symmetric difference rev range (triple dot) will here compare the changes on
24-
the current branch (the PR branch) against its merge-base in `origin/main`. This
25-
is different than comparing directly against `origin/main` if the branches have
24+
the current branch (the PR branch) against its merge-base in `origin/HEAD`. This
25+
is different from comparing directly against `origin/HEAD` if the branches have
2626
diverged, and is usually what you want when comparing changes in a PR. For more
2727
info see the section on "SPECIFYING REVISIONS" in `man git-rev-parse(1)`.
2828

@@ -47,6 +47,15 @@ involved.
4747

4848
![diffview symdiff demo](https://user-images.githubusercontent.com/2786478/229858634-c751ebe3-cc43-48de-adda-bf0b71fa2ce7.png)
4949

50+
> NOTE: If Git complains `fatal: Not a valid object name origin/HEAD` then it
51+
> likely means that your local origin remote doesn't have a default branch
52+
> configured. You can have Git automatically query your remote and detect its
53+
> default branch like this:
54+
>
55+
> ```sh
56+
> git remote set-head -a origin
57+
> ```
58+
5059
[^1]: The files as they currently exist on disk.
5160
5261
### Comparing Changes From the Individual PR Commits
@@ -56,13 +65,13 @@ review the changes introduced in each of those commits individually. To do
5665
this, you can use `:DiffviewFileHistory`:
5766
5867
```vim
59-
:DiffviewFileHistory --range=origin/main...HEAD --right-only --no-merges
68+
:DiffviewFileHistory --range=origin/HEAD...HEAD --right-only --no-merges
6069
```
6170
6271
Here we are again using a symmetric difference range. However, symdiff ranges
6372
have different behavior between `git-diff` and `git-log`. Whereas in `git-diff`
6473
it compares against the merge-base, here it will select only the commits that
65-
are reachable from *either* `origin/main` *or* `HEAD`, but not from both (in
74+
are reachable from _either_ `origin/HEAD` _or_ `HEAD`, but not from both (in
6675
other words, it's actually performing a symmetric difference here).
6776
6877
We then use the cherry-pick option `--right-only` to limit the commits to only
@@ -80,7 +89,7 @@ create a new commit from within the editor:
8089
8190
### Use a Git Wrapper Plugin (Recommended)
8291
83-
Diffview.nvim *is not*, and *does not try to be* a complete git wrapper. As
92+
Diffview.nvim _is not_, and _does not try to be_ a complete git wrapper. As
8493
such, there are a number of features offered by such plugins that won't ever be
8594
implemented here, because they are deemed out-of-scope. It's therefore
8695
recommended to use some form of a Git wrapper plugin in order to get a more

0 commit comments

Comments
 (0)