[delayed]
Why isn't the 'edit' command mentioned? It's one of the most useful features. It can be used for splitting commits, for example. Mark the commit you want to split to be edited. The commit replay is going to stop after that commit. Now:<p><pre><code> git reset HEAD^1 (NO --hard!)
git commit --patch ...
git rebase --continue
</code></pre>
You want to add some pending changes to the previous commit? No problem:<p><pre><code> git commit --patch --amend ...
</code></pre>
You want to move the pending changes to future commits?<p><pre><code> git stash
git rebase --continue
git stash pop</code></pre>
After more than a decade of using git, I know that my comfort with rebase, and confidence that I wont make an error I can't undo, comes from knowing that I can always abort. And assuming it wasn't garbage collected, I can always get back to orphaned commits, or the commit before I rebased, as long as I keep their hashes. I can definitely look back on my less confident days as times when I wrongly assumed I was walking a tightrope where screwing up was painful and expensive, and easy to take the wrong path, and abort is the universal solvent to all of that.<p>I do still find myself tripping up on whether the next appropriate step is to make a commit or continue the rebase, as that is dependent on if you're in a merge conflict or just editing a commit. But even when I get that wrong, and collapse two commits together, abort saves the day.
You don't need to keep their hashes because git keeps them for you. If you realise too late that things went terribly wrong, you can get the pre-rebase hashes with "git reflog". (It can take a little getting used to knowing how to identify them quickly after a rebase but they're there.)
I feel like if you're scared of rebasing, you don't actually understand git.
My fear has never been rebasing itself, but that I make some kind of mistake with a random change conflict and don't notice it because it's not tested for directly. But I'm also not sure if that's categorically a git fear. (Edit: related to this, I think this sort of minor "itchy worry" is grounded in how sometimes conceptually simple diffs look messy during conflict resolution.)
If all I'm doing with git rebase is reorganising my commits, and I have to deal with conflicts, after I'm done, I always git diff my pre-rebase head with post rebase head commit hash. I can quickly see I've messed something up if the diff isn't empty. For more complex tasks it's best to leave the rearranging until last, but where not possible, the diff is still pretty useful to double check my work.
Reflog is, as the article says, the permission to do all kinds of crazy things, including rebasing. Once you realize any committed state is recoverable for a good period of time it really frees you.<p>Plus you can always take a note of the commit hash before you do anything crazy. But reflog means you don't <i>have</i> to.<p>Git really does have all the features you need. I wouldn't argue with anyone complaining about the UI to get there. But it's all in there somewhere.
The part where git needs to be “understood” is the entire problem. “Do one thing and do it well” was the whole mantra, which was completely ignored with the disaster that is git. It’s objectively awful.
It could be so much better. At the same time, it’s one of the core tools for a developer. You’ll learn it eventually. You’re going to be using version control for decades. I’ve met devs many years into their careers who don’t understand rebase. It’s like going to a metal shop and they’re complaining about the learning curve on their welder and half the tradesmen are still at a novice level.
I found the VS Code GitLens extension to be a good abstraction for interactive rebase. It provides a drag-and-drop UI with a dropdown to select actions applied to each commit. That is much easier than editing a text file.<p>Here's a GIF I found with Google: <a href="https://yogwang.site/2025/cursor-vscode-gitlens-rebase-editor/rebase.gif" rel="nofollow">https://yogwang.site/2025/cursor-vscode-gitlens-rebase-edito...</a>
That “-I” really needs to be lowercase.
I wish there were a shorthand for<p><pre><code> x git commit --amend --reset-author --no-edit
</code></pre>
I use that one very frequently (after a fixup, of course) because I want the author date on amended commits to reflect the last time I edited them, not the first time I committed them.
But you can make your own alias?<p><pre><code> > git config --global alias.whatever_you_want 'commit --amend --reset-author --no-edit'
</code></pre>
<a href="https://git-scm.com/book/ms/v2/Git-Basics-Git-Aliases" rel="nofollow">https://git-scm.com/book/ms/v2/Git-Basics-Git-Aliases</a>
i edit my commit dates constantly for various reasons<p>get ahead at work? split into commits and make it look like multiple days of work<p>work on your own IP during work hours? edit the timestamp to be outside work hours (i even have a script for this)
- i often go back like 5 commits and make changes like this<p>- git rebase -i <commit-hash>^<p>- select edit<p>- git reset --soft HEAD~<p>- make some changes<p>- git add . && git commit -m "changes"<p>- git rebase --continue<p>- Am I using git rebase wrong?
I still make a throwaway branch before a complicated rebase. It costs nothing and turns the whole operation into a low-stakes edit instead of a leap of faith.
I also thought rebase was scary long ago. It is scary in the sense if one messes something up without realizing and then pushes to master…<p>Besides interactive rebase, my other favorite command is “git log —-oneline origin/master..HEAD”<p>It shows me exactly where I am…
<p><pre><code> git commit —fixup=<commit-id>
git rebase -i —autosquash
</code></pre>
This is my best friend
Big rebase fan here. I find myself using squash the most.
<p><pre><code> pick a1b2c3d Add user model
s e4f5g6h Fix typo in user model
pick i7j8k9l Add login endpoint
s m0n1o2p WIP debugging login endpoint
s feedbee fixed login endpoint
s deadbee fixed login endpoint
s adebade fixed login endpoint
s abcdefg actually fixed login endpoint
</code></pre>
Of course, I get reminded about f/fixup every now and then - think "golly, that will save a second or two" and promptly forget.
I use rebase so much but it only feels comfortable because I follow a workflow while rebasing.
Another git command I love using is `git add -p`. I always want to commit in chunks as I go but sometimes I wait to long or realize later I could have broken it up. Being able to select only pieces of a file to add to a specific commit is so great. Editing the chunks manually can be a bit intimidating but since it only stages the change you can always restore the file and try again if the diff doesn't look right after the add.
I typically work with commit chains of at least 5 commits in various states of code review, so I spend at least 60% of my development time editing an old commit in the middle of a rebase -i.
I really love the emacs interactive rebase mode, which comes up by default when you have EDITOR=emacs and do rebase -i.<p>I know you can do this from within magit as well but I've never gotten into that workflow.
rebase interactive is so great, such a powerful tool.<p>it's the one clear tool that i used all the time. moving to jj, it has lots of amazing tools starting with `jj edit` to go change the past safely & conveniently, with much less pain. but i miss the direct powerful data-driven experience of seeing the timeline in a text file, and picking what to do with it. sometimes.<p>imo every dev should work to get some competency with git rebase! it's an amazing tool. there's few other systems that give such direct control. it's top layer is, perhaps, the excel of version control?
sometimes i wish mercurial won, if nothing else for the fact that i found its ux to be more enjoyable. I respect and use git, but never got comfortable with merging. im thankful AI can automate it for me now
I cannot recall the last time I committed manually, let alone rebase manually. An agent can do it for you faster and without making mistakes.