Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

During a git rebase, how can I keep the original and discard changes?

Tags:

I am doing a rebase and have come to a file with conflicts, but these conflicts are basically impossible to resolve. The best way to deal with the situation would be to tell git to ignore the changes and keep the original. I can then go back and re-edit the file to make the changes.

How can I do this?

like image 888
ericg Avatar asked Dec 19 '11 19:12

ericg


People also ask

Does git rebase overwrite changes?

If another user has rebased and force pushed to the branch that you're committing to, a git pull will then overwrite any commits you have based off that previous branch with the tip that was force pushed.

How do I save changes in git rebase?

To save your changes and exit the document, type :wq! and press Enter key. It should appear at the end of the document like this. To exit the document without saving, type :q! and press Enter key.

Does git rebase lose history?

rebase does not lose any history at all. Every single commit that you used to have is still there.

How do I stop rebase abortion?

You can run git rebase --abort to completely undo the rebase. Git will return you to your branch's state as it was before git rebase was called. You can run git rebase --skip to completely skip the commit.


1 Answers

If you have encountered a merge conflict you can do this

git checkout --ours file 

or the other way round

git checkout --theirs file 
like image 143
three Avatar answered Sep 17 '22 13:09

three