3 ms·
> scary rebase -i commands that can leave your tree in a half-broken state if you so much as sneeze `git rebase --abort` exists. One can also set a tag or some
by jolmg 3mo ago
> scary rebase -i commands that can leave your tree in a half-broken state if you so much as sneeze
`git rebase --abort` exists. One can also set a tag or something before doing the rebase, do whatever, then `git reset --hard $set_tag` to go back. Nothing to be scared of. Not like the prior state is lost.
- catlifeonmars 3mo agoDo you use git reflog?
- jolmg 3mo agoOne can also use that, or just `git log -n1` and taking note of the commit hash. So many options.
- ibizaman 3mo agoI do when I forget to run the git branch comment before. But I find it still hard to understand exactly which commit to reset to in the reflog.
- _ikke_ 3mo agoThe branch reflog (git reflog <branchname> or git log -g <branchname>) is a lot easier to follow in the case of rebase than the HEAD reflog (which gets an entry for each commit that gets checked out / applied).
- rmunn 3mo agoI have so many branches named `temp` or `before-rebase` for exactly that reason; I'm using them effectively as tags, but branches can be moved around with less ceremony than tags (since tags are designed to be for things like v1.2.3, placed once and then almost never moved again), so I usually just do `git branch before-rebase/some-feature` before running a big `rebase -i`. I've almost never needed to run `get reset before-rebase`. But I have often done `git log -p before-rebase` and compared that to the post-rebase state of the branch, to ensure that the merge-conflict resolution(s) that came up during the rebase haven't accidentally introduced an unintended change.
- jolmg 3mo ago> but branches can be moved around with less ceremony than tags `git tag -f` to move a tag. Personally, I just do `git show` when I'm feeling cautious, but I can generally just scroll up to find the last `git commit` I did with the hash in the output. `git reflog` should also have record of it, so everything else is kind of extra.
- rmunn 3mo agoGood point, that's no more ceremony than moving a branch. I guess I've just gotten "branches are movable tags" so deep into my hindbrain that I absorbed "tags are hard to move". But that's not actually true, and for what I'm doing (save this point in history for a while) a tag makes slightly more sense, semantically, than a branch.
- deleted 3mo ago[deleted]
- chrismorgan 3mo agoDiffing diffs is so valuable for that reason, seriously underrated. Once I even found a use case for diffing diff diffs. I also often wish to edit commits or resolve rebase conflicts or whatever by editing the patch rather than the files.
- andrepd 3mo agoNo need for that even. Just git reflog and rewind back to any spot your want!
- dalmo3 3mo ago> `git rebase --abort` exists Exactly. 50% of the times I type git rebase it is followed by --abort.
- account42 3mo agoYou don't even need to set a safety tag like that anywhere in git, the reflog does that for you automatically.
- BeetleB 3mo agojj undo You can't get simpler than that.