skip to content

Rebase and History Rewriting

You will learn to rewrite history deliberately: squash, reorder and edit commits with interactive rebase, move work with rebase --onto and cherry-pick, and scrub secrets with git-filter-repo. Interviewers pair it with the consequences — force-push etiquette on shared branches and reflog as the way back.

part ofGitoverview, primer and where to startread it →
on this pageshow

questions

page 2 of 2

In Git, how do you tell whether a commit was already cherry-picked upstream?

level: seniorimportance: nice to knowfreq 25%

basics

~20 s

Compare by patch content, not by SHA. git cherry <upstream> <head> marks each commit - when an equivalent change already exists upstream and + when it does not, using a patch-id — a hash of the diff that ignores line numbers and whitespace context.

open as a page

How do you drive a Git interactive rebase from a script without an editor?

level: seniorimportance: nice to knowfreq 20%

basics

~10 s

Set GIT_SEQUENCE_EDITOR to a command that edits or simply accepts the todo file. GIT_SEQUENCE_EDITOR=: git rebase -i --autosquash <base> accepts the generated plan unchanged, while a sed command can rewrite the verbs programmatically.

open as a page

showing 31–32 of 32