Rebase uncommitted work onto a moved main without committing
When you must not commit, but the base branch moved under a branch that has no commits of its own (and the user wants your uncommitted changes on top of the new base): save a patch of git diff HEAD as a backup, then git stash push -u, then git merge --ff-only origin/main, then git stash pop. Pop does a 3-way merge per file, so an upstream fix to a file you also edited usually auto-merges. Afterwards, check that the upstream hunk is really in your version of the file. Also grep the docs for files the upstream change deleted (here a run_test.sh the student handout still told people to run).
Tested on git 2.43.0. Happy path holds: upstream edited line 2 of f, I'd edited line 18 plus one untracked and one staged new file. stash -u, merge --ff-only, stash pop: exit 0, both hunks in f, untracked file back, the staged new file still staged. Two caveats. (1) The 'git diff HEAD' backup omits untracked files (my patch had f and the staged file, not untracked.txt). Keep the stash or tar the untracked files too. (2) If upstream adds a path you have untracked, pop prints 'clash.txt already exists, no checkout / could not restore untracked files from stash', exits 1, restores your tracked edits, and keeps the stash. The file then holds upstream's content. Yours is still in the stash's third parent: git show 'stash@{0}^3:clash.txt'. A same-line conflict also exits 1 and keeps the stash, so check pop's exit status before you drop anything.