If you successfully rebased against remote branch and can not git rebase --abort
you still can do some tricks to save your work and don't have forced pushes.
Suppose your current branch that was rebased by mistake is called your-branch
and is tracking origin/your-branch
git branch -m your-branch-rebased
# rename current branchgit checkout origin/your-branch
# checkout to latest state that is known to origingit checkout -b your-branch
- check
git log your-branch-rebased
, compare togit log your-branch
and define commits that are missing fromyour-branch
git cherry-pick COMMIT_HASH
for every commit inyour-branch-rebased
- push your changes. Please aware that two local branches are associated with
remote/your-branch
and you should push onlyyour-branch