Skip to content

Commit bd10fce

Browse files
committed
Add a section for how to review code more easily
1 parent 586474f commit bd10fce

File tree

3 files changed

+36
-0
lines changed

3 files changed

+36
-0
lines changed

src/git.md

+36
Original file line numberDiff line numberDiff line change
@@ -441,6 +441,42 @@ tradeoff. The main advantage is the generally linear commit history. This
441441
greatly simplifies bisecting and makes the history and commit log much easier
442442
to follow and understand.
443443

444+
## Review suggestions
445+
446+
**NOTE**: This section is for *reviewing* PRs, not authoring them.
447+
448+
### Hiding whitespace
449+
450+
Github has a button for disabling whitespace changes we recommend using.
451+
You can also use `git diff -w origin/master` to view changes locally.
452+
453+
![hide whitespace](./img/github-whitespace-changes.png)
454+
455+
### Fetching PRs
456+
457+
To checkout PRs locally, you can use `git fetch upstream pull/NNNNN/head && git checkout FETCH_HEAD`.
458+
459+
You can also use github's cli tool. Github shows a button on PRs where you can copy-paste the command to check it out locally. See <https://cli.github.com/> for more info.
460+
461+
![`gh` suggestion](./img/github-cli.png)
462+
463+
### Moving large sections of code
464+
465+
Git and Github's default diff view for large moves *within* a file is quite poor; it will show each
466+
line as deleted and each line as added, forcing you to compare each line yourself. Git has an option
467+
to show moved lines in a different color:
468+
469+
```
470+
git log -p --color-moved=dimmed-zebra --color-moved-ws=allow-indentation-change
471+
```
472+
473+
See https://git-scm.com/docs/git-diff#Documentation/git-diff.txt---color-movedltmodegt for more info.
474+
475+
### range-diff
476+
477+
See [the author section](#git-range-diff). This can be useful for comparing code that was force-pushed
478+
to make sure there are no unexpected changes.
479+
444480
## Git submodules
445481

446482
**NOTE**: submodules are a nice thing to know about, but it *isn't* an absolute

src/img/github-cli.png

26.2 KB
Loading

src/img/github-whitespace-changes.png

28.5 KB
Loading

0 commit comments

Comments
 (0)