Git rebase removing more recent changes?

If there are conflicts between master and your a branch, the rebase will stop at the point where the conflict exists and expects you to fix it.

First off, to get to the original state of your branch, you can do git rebase --abort. This will undo the attempted rebase.

If you are still in the middle of the rebase, you can do git diff to see where the conflicts are. You'll see something like this in the conflict files

<<<<<<< HEAD
...
=======
....
>>>>>>> branch-a

You can edit the file to fix the conflicts by choosing the code that you want to keep and removing the <<<< ===== >>>>>>> lines.

Once you've finished editing the files and conflicts, you can run git add . and then git rebase --continue. The rebase will continue moving your commits up to HEAD. At any point, you may or may not run into more conflicts. If you don't, you'll see that the rebase worked successfully and then you'll be able to push your changes to your branch. Since you've rebased, however, you'll only be able to do perform a forced push since your commit refs will have changed from the ones on the remote.


Same thing happened to me. What's happening is you are still in the middle of a rebase and it's not done so your latest up to date modifications should still be ok if it was committed.

The rebase is going back from the beginning of all the commits in the past that you might have to catch up on (for instance, if your other developer made 10 commits from a few days ago that you need to integrate in your app). Or simply don't accept it or whatever fits best for your app.

Then hit the "+" to add it/include it onto your local branch. (No need to commit/push since you're just bringing it onto your local branch to work off of that).

Then:

git rebase --continue

Then go one by one through all the old commits that have conflicts with your newest commit until you get to your latest which should be reassuring once you see those recent modifications that look normal.

Tags:

Git