Crafting PRs Reviewers Will Love
2025-06-22
m: Side Menu with TOCo: Overview Mode
# When rerere is enabled (rerere.enabled = true), Git records how you
# resolve merge conflicts and reuses those resolutions in future merges,
# automating the conflict resolution process for identical or similar
# conflicts. This feature is particularly useful in long-running branches
# to minimize manual conflict resolution effort.
[rerere]
enabled = true
# When rebase.autoStash is enabled (rebase.autoStash = true), Git
# automatically stashes any local changes before a rebase operation and
# reapplies them after the rebase completes, facilitating a smoother
# rebase process for working directories with uncommitted changes.
[rebase]
autoStash = true
# Other useful defaults:
[init]
defaultBranch = main
[push]
default = simple
[checkout]
defaultRemote = origin
# If you have Beyond Compare installed (https://www.scootersoftware.com/),
# use these settings to configure it as your default mergetool:
[merge]
tool = bc3
[mergetool "bc3"]
cmd = /usr/bin/bcompare $LOCAL $REMOTE $BASE $MERGED
# Some handy aliases.
[alias]
st = status
ci = commit
br = branch
co = checkout
df = diff
dc = diff --cached
lg = log -p
lol = log --graph --decorate --pretty=oneline --abbrev-commit
lola = log --graph --decorate --pretty=oneline --abbrev-commit --all
ls = ls-files
# Show files ignored by git:
ign = ls-files -o -i --exclude-standardalias gb='git branch'
alias gba='gb -a'
alias gbc='gb --show-current'
alias gss='git status --untracked-files=no'
alias gs='git status'
alias gd='git diff'
alias gdc='git diff --cached'
alias gg='git grep -n'
alias ggi='git grep -ni'
alias gds='git diff --staged'
alias gc='git commit'
alias gpr="git pull --rebase" # <-- important!
alias gprom="git pull --rebase origin main" # <-- important!
alias gls='git ls-files'
alias gmb='git merge-base HEAD origin main' # <-- important!
alias gll='git log --graph --decorate --pretty=oneline --abbrev-commit'
alias gllmb='gll $(gmb)..HEAD'
alias grib='git rebase -i $(gmb)' # <-- important!~/.ssh/config file:git clone gh:NVIDIA/cccl.tpn = my fork/GH username)main is always tracking NVIDIA/cccl.tpn/main that hasn’t been updated in 8 months.main, the main revision upon which your branch will be based is known as the merge-base.alias gmb='git merge-base HEAD origin main'main:% gllmb
* afb1290cc (HEAD -> 4310-add-scan_op-support-to-cudacoop-block_scan-routines, tpn/4310-add-scan_op-support-to-cudacoop-block_scan-routines) Improve invariants.
* 356514111 Tweak docstrings a bit more.
* 49132575a Export `block_scan` symbol; do not use `ScanOp('+')` as default arg.
* 481375f94 Remove redundant/obsolete code.
* cd1467134 Vastly improve docstrings for all block_scan routines.
* 8aace835d Minor cosmetic tweaks of ScanOp-related functionality.
* 841fab0c8 Tweak module docstring.
* 1292c4c39 Fix 2D sizes; add float64 test.
* 4d7502566 Working checkpoint commit; all test_block_scan.py tests now pass!
* 6adf8f575 Checkpoint commit of block scan scan op process.
* 712d9e3b6 Rename DependentOperator to DependentPythonOperator.
* 6900f83df Checkpoint commit of test_block_scan.py prior to o1-pro revamp.
* 441f57fb0 Checkpoint commit of test_block_scan.py prior to ChatGPT o1-pro.
* 0360c5167 Checkpoint commit of local _block_scan.py changes prior to test refactoring.
* 0df7d0de5 Initial implementation of new tests for block_scan routines.
* ddb3da6ec Relocate Complex type scaffolding to helpers.py.
* da6c9a2e8 Implement exclusive_scan and inclusive_scan in block_scan module.
* 155a7712f Implement ScanOp class and supporting helpers.
%tpn remote’s 4310-add-scan_op-support-to-cudacoop-block_scan-routines branch directly:merge-base revision of the original branch.gllmb output from earlier.% and leading % gmbll.^* with pick.:%!tac (tac = reverse cat)4310-scan_op. Push to Github frequently.-v2 branch from the initial dev branch (4310-scan_op in our case).4310-scan_op branch, and it’s the active branch in our repo.-v2 branch where we’ll do all our new work.main:
git reset $(gmb)git add -i usage that simulates the workflow I’m proselytizing in this deck.git add -i UI to replicate the first commit in that v2 branch.
git add -i work.~/.gitconfig on nv1:# sudo apt install -y git-delta
# https://dandavison.github.io/delta/side-by-side-view.html
[core]
# Comment out this next line to disable delta for e.g. `git show ...`
pager = delta
[interactive]
# Comment-out this next line to disable delta and go back to unified diffs.
diffFilter = delta --color-only --features=interactive
[delta]
features = decorations
side-by-side = true
line-numbers-left-format = ""
line-numbers-right-format = "│ "
[delta "interactive"]
keep-plus-minus-markers = false
[delta "decorations"]
commit-decoration-style = blue ol
commit-style = raw
file-style = omit
hunk-header-decoration-style = blue box
hunk-header-file-style = red
hunk-header-line-number-style = "#067a00"
hunk-header-style = file line-number syntaxgit add -i; 5: patch>
* → Selects everything1 5 10 → Selects 1, 5, and 101-5 7-8 10 12-13 → Selects 1-5 (e.g. 1,2,3,4,5), 7-8, 10, 12-13-5 → Unselects 5 (i.e. if added by mistake)-* → Unselects everything(1/1) Stage this hunk [y,n,q,a,d,s,e,?]? ?
y - stage this hunk
n - do not stage this hunk
q - quit; do not stage this hunk or any of the remaining ones
a - stage this hunk and all later hunks in the file
d - do not stage this hunk or any of the later hunks in the file
s - split the current hunk into smaller hunks
e - manually edit the current hunk
? - print helpy, n, and q frequently.a, d, se(1/6) Stage this hunk [y,n,q,a,d,j,J,g,/,s,e,?]? ?
y - stage this hunk
n - do not stage this hunk
q - quit; do not stage this hunk or any of the remaining ones
a - stage this hunk and all later hunks in the file
d - do not stage this hunk or any of the later hunks in the file
j - leave this hunk undecided, see next undecided hunk ***
J - leave this hunk undecided, see next hunk ***
g - select a hunk to go to ***
/ - search for a hunk matching the given regex ***
s - split the current hunk into smaller hunks
e - manually edit the current hunk
? - print help***s→ split the current hunk into smaller hunkse→ manually edit the current hunk
'-' lines, make them ' ' lines.'+' lines, delete them.git reflog or the Stage 0 push to somewhere remote), there’s no risk of completely losing code.git add -i, 5> patch, git commit loop until finished.git rebase -i $(gmb).
git rebase --interactive $(git merge-base HEAD origin main)git rebase -i $(gmb)alias grib='git rebase -i $(gmb)’grib to craft a git history that I can then use to demonstrate grib.git commit --amend.gc -m fixup.gc -m "fixup remove depfunc" so I remember where to inject the fixup during rebase.N.B. Uncomment this to print ... lines in the very first git add -i example.# Commands:
# p, pick <commit> = use commit
# r, reword <commit> = use commit, but edit the commit message
# e, edit <commit> = use commit, but stop for amending
# s, squash <commit> = use commit, but meld into previous commit
# f, fixup [-C | -c] <commit> = like "squash" but keep only the previous
# commit's log message, unless -C is used, in which case
# keep only this commit's message; -c is same as -C but
# opens the editor
# x, exec <command> = run command (the rest of the line) using shell
# b, break = stop here (continue rebase later with 'git rebase --continue')
# d, drop <commit> = remove commit
# l, label <label> = label current HEAD with a name
# t, reset <label> = reset HEAD to a label
# m, merge [-C <commit> | -c <commit>] <label> [# <oneline>]
# create a merge commit using the original merge commit's
# message (or the oneline, if no original merge commit was
# specified); use -c <commit> to reword the commit message
# u, update-ref <ref> = track a placeholder for the <ref> to be updated
# to this position in the new commits. The <ref> is
# updated at the end of the rebase
#In order of how frequently I use them for every given PR…
fixup commit from the last command to wherever you want it injected.
fixup commit where I want it.git commit: inject a new commit.git commit --amend: meld your changes into the prior commit.git rebase --continue.edit.2,$ s/^pick/exec git commit --amend --no-edit -m "$(git show -s --format=%B | sed 's\/^MINOR: \/\/')"\rpick/exec git commit --amend --no-edit --author="Dave Cutler <davec@microsoft.com>"exec git commit --amend --no-edit -m "$(git show -s --format=%B)$(echo; echo 'Co-authored-by: Linus Torvalds [linus@linuxfoundation.org](mailto:linus@linuxfoundation.org)')"git pull --rebase. Or gpr alias.main? git pull --rebase origin main (or gprom).git push --force-with-lease (or gpfwl).git reflog if you really eff things up.