I've made a big mistake of rebasing a branch into master instead of the master into branch. So now instead of having changes of master in a branch, I have master that's out of sync with remote repo.
How can I take changes back?
I've made a big mistake of rebasing a branch into master instead of the master into branch. So now instead of having changes of master in a branch, I have master that's out of sync with remote repo.
How can I take changes back?
If your remote repo is still ok, just
git checkout anybranch
git branch -D master
git fetch --all
git checkout master
When you make mistakes with the branches and where they point, you can get rescued by git reflog
.
git reflog
will show you where the branch was pointing to before. So if your rebase is wrong, you can "undo" it by pointing the branch to where it used to be with:
git reset --hard HEAD@{1}
Change 1 to be another number depending where the commit that you want is in the list that reflog provides.
The reflog is also useful for many other mistakes one can make.