3 ms·
> Create a backup branch and push it up to GitHub/Gitlab/etc. This backup branch will have all your work nice and safe in case you need to start over. The way
by lelandfe 5y ago
> Create a backup branch and push it up to GitHub/Gitlab/etc. This backup branch will have all your work nice and safe in case you need to start over.
The way I teach programmers to do this is to make use of cheap branches and to instead work on a temporary branch, and eventually use ‘git reset --hard branchName’ to turn your original branch into a mirror of the temporary one when ready.
This is a helpful mindset to get into; you can just throw it away in a worst case.
- avgcorrection 5y agoFor rebasing specifically I often don’t make a temporary branch. I’ll use the reflog and reset to the commit hash if something gets messed up. Those “backup” branches really aren’t that for me. They’re just named commits which makes it easier to figure out where I was. But they are sometimes necessary since the reflog isn’t always nice and easy to read. And pushing that branch to a remote? That’s unnecessary unless you want to delete the whole repo and clone it again in case you “mess it up”. Well, I guess that could be useful in a tutorial.
- lelandfe 5y agoBear in mind we’re teaching folks how to rebase - reflog can be an intimidating dive for a first blush discussion
- dvlsg 5y ago`git reset --hard ORIG_HEAD` is often enough to "undo" a rebase that went haywire. `git rebase --abort` can be helpful too, if you run into some unexpected merge conflicts along the way.