Quantcast
Channel: Undoing a git rebase - Stack Overflow
Browsing all 23 articles
Browse latest View live

Answer by mrigendra for Undoing a git rebase

What I usually do is git reset #commit_hash to the last commit where I think rebase had no effect. then git pull Now your branch should match exactly like master and rebased commits should not be in...

View Article


Answer by Andrew for Undoing a git rebase

For newbies/anyone too scared of doing a hard reset, you could checkout the commit from the reflog, and then save it as a new branch. git reflog Find the commit just before you started rebasing. You...

View Article


Answer by Damodar P for Undoing a git rebase

git reset --hard origin/{branchName} is the correct solution to reset all your local changes done by rebase.

View Article

Answer by devconsole for Undoing a git rebase

If you are on a branch you can use: git reset --hard @{1} There is not only a reference log for HEAD (obtained by git reflog), there are also reflogs for each branch (obtained by git reflog...

View Article

Answer by Meligy for Undoing a git rebase

git reflog will show you all the changes before and after rebase, and allow you to find the right one to reset to. But I'm surprised no one mentioned this other super simple way here yet: Also, as...

View Article


Answer by Hardev for Undoing a git rebase

Let's say I rebase master to my feature branch and I get 30 new commits which break something. I've found that often it's easiest to just remove the bad commits. git rebase -i HEAD~31 Interactive...

View Article

Answer by Sergey P. aka azure for Undoing a git rebase

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...

View Article

Answer by meshfields for Undoing a git rebase

If you mess something up within a git rebase, e.g. git rebase --abort, while you have uncommitted files, they will be lost and git reflog will not help. This happened to me and you will need to think...

View Article


Answer by Maksym for Undoing a git rebase

In case you had pushed your branch to remote repository (usually it's origin) and then you've done a succesfull rebase (without merge) (git rebase --abort gives "No rebase in progress") you can easily...

View Article


Answer by Matheus Felipe for Undoing a git rebase

Following the solution of @Allan and @Zearin, I wish I could simply do a comment though but I don't enough reputation, so I have used the following command: Instead of doing git rebase -i --abort (note...

View Article

Answer by Kris for Undoing a git rebase

Using reflog didn't work for me. What worked for me was similar to as described here. Open the file in .git/logs/refs named after the branch that was rebased and find the line that contains "rebase...

View Article

Answer by Allan for Undoing a git rebase

Charles's answer works, but you may want to do this: git rebase --abort to clean up after the reset. Otherwise, you may get the message “Interactive rebase already started”.

View Article

Answer by Alex Gontmakher for Undoing a git rebase

I actually put a backup tag on the branch before I do any nontrivial operation (most rebases are trivial, but I'd do that if it looks anywhere complex). Then, restoring is as easy as git reset --hard...

View Article


Answer by Pat Notz for Undoing a git rebase

Actually, rebase saves your starting point to ORIG_HEAD so this is usually as simple as: git reset --hard ORIG_HEAD However, the reset, rebase and merge all save your original HEAD pointer into...

View Article

Answer by Aristotle Pagaltzis for Undoing a git rebase

Resetting the branch to the dangling commit object of its old tip is of course the best solution, because it restores the previous state without expending any effort. But if you happen to have lost...

View Article


Answer by Greg Hewgill for Undoing a git rebase

For multiple commits, remember that any commit references all the history leading up to that commit. So in Charles' answer, read "the old commit" as "the newest of the old commits". If you reset to...

View Article

Answer by CB Bailey for Undoing a git rebase

The easiest way would be to find the head commit of the branch as it was immediately before the rebase started in the reflog... git reflog and to reset the current branch to it (with the usual caveats...

View Article


Undoing a git rebase

Does anybody know how to easily undo a git rebase? The only way that comes to mind is to go at it manually: git checkout the commit parent to both of the branches then create a temp branch from there...

View Article

Answer by user3638751 for Undoing a git rebase

I tried all suggestions with reset and reflog without any success. Restoring local history of IntelliJ resolved the problem of lost files

View Article

Answer by DylanYoung for Undoing a git rebase

It annoys me to no end that none of these answers is fully automatic, despite the fact that it should be automatable (at least mostly). I created a set of aliases to try to remedy this:# Useful...

View Article
Browsing all 23 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>