Git Cheat Sheet · Integrate
Abort a merge or a rebase
git merge --abort · git rebase --abort
If a merge or a rebase goes wrong, you can cancel everything as long as it is not finished: git merge --abort or git rebase --abort puts your branch and your files back exactly as they were before the operation.
What it does
Cancels the current operation and puts the branch back in its previous state.
A use case
There are more conflicts than expected and you would rather discuss them before continuing.
On the command line
git merge --abort- Cancels a merge in progress.
git rebase --abort- Cancels a rebase in progress.
git cherry-pick --abort- Cancels a cherry-pick in progress.
git revert --abort- Cancels a revert in progress.
In Merathon
- In the banner at the top of the right panel, click "Cancel operation" or "Cancel rebase".
Frequently asked questions
How do I undo a rebase that has already finished?
git reflog shows where your branch was before the rebase; git reset --hard <hash> puts it back there.
Does git merge --abort erase my changes?
It restores the state from before the merge. Uncommitted changes present before the merge can be lost: commit or stash before merging.