Oh Shit, Git?
Modern Git commands & safer workflows
- Many advocate preferring
git switch/git restoreovergit checkoutto separate “change branch” from “restore files,” though some note these commands are still labeled “experimental” in docs. - Several suggest avoiding
git reset --hardexcept when you really understand the consequences, recommending:git branch -f <branch> <commit>orgit reset --soft/--mixedto “move” branches without nuking work.git reset --keepto retain uncommitted changes when moving HEAD.git stash/stash --allas a safer “clean tree” approach thanreset --hard+clean -xfd.
Mental model, reflog, and low-level tools
- Strong focus on Git as a graph of commits and refs; confusion arises from the CLI mixing low-level “plumbing” and high-level “porcelain.”
git resetvariants are widely described as hard to grasp; the “Reset demystified” chapter is frequently cited (within the thread) as essential reading.git reflogis highlighted as the real safety net for “oh shit” moments, letting you recover previous states; some even copy the.gitdirectory as an extra backstop.
Alternatives and UX: jj, GUIs, TUI
- Jujutsu (
jj) gets repeated praise as a Git-compatible VCS with simpler, more consistent commands (e.g.,jj undo,jj op log,jj split,jj rebaseflows). - Many argue beginners should start with visual tools (Fork, GitHub Desktop, Magit, lazygit, etc.) to see the commit tree and make rebases/cherry-picks more intuitive.
- Others warn GUIs hide concepts, leading to deeper confusion when something breaks and only the CLI or reflog can fix it.
Recipe sites, help culture, and risk
- The “Oh Shit, Git” style of copy-paste recipes is polarizing:
- Fans: great quick references, especially without in-house Git experts.
- Critics: generic recipes can subtly corrupt history or lose work; better to ask experienced teammates or rebuild a small personal repo than run commands you don’t understand.
Philosophy of commits, branches, and other VCS
- Debate over local vs remote branches: some advocate “all branches are remote,” frequent pushes, and aggressive
reset --hard; others value private WIP branches and curated public history. - Several emphasize frequent local commits (even messy) and then cleaning up via rebase/squash before sharing.
- Comparisons arise: some say Git is powerful but poorly designed at the UI level; others defend it as “not that hard” if you learn the core concepts. SVN and Mercurial are mentioned as more intuitive but less dominant.