Reputation: 5176
My local branch someNewFeature
has mistakenly diverged.
Running git status, shows this:
$ git status
On branch someNewFeature
Your branch and 'origin/someNewFeature' have diverged,
and have 8 and 1 different commit each, respectively.
(use "git pull" to merge the remote branch into yours)
nothing to commit, working directory clean
The git commit tree for the local branch looks like this:
* jjjjjjj commit 10
* iiiiiii commit 9
* hhhhhhh commit 8
* ggggggg commit 7
* fffffff commit 6
* eeeeeee commit 5
* ddddddd commit 4
* ccccccc commit 3
| * bbbbbbb Diverged commit
|/
* aaaaaaa Base commit
I want to address the divergence by applying all the commits sequentially, i.e. it should look like this:
* jjjjjjj commit 10
* iiiiiii commit 9
* hhhhhhh commit 8
* ggggggg commit 7
* fffffff commit 6
* eeeeeee commit 5
* ddddddd commit 4
* ccccccc commit 3
* bbbbbbb Diverged commit
* aaaaaaa Base commit
Bonus: If you could guess how I might have done this, I'd appreciate the insight.
Upvotes: 0
Views: 625
Reputation: 6702
If you are afraid to mess up your repository and not sure about your git commands, I suggest GitUp to work on git repositories. It has all merging / rebasing capabilities through visualization. It also has undo/redo function so if you mess up something you can always revert back. You can even re-order your commits.
Also here is a CLI answer: As far as I understand, you have a local branch named someNewFeature and you are working on that almost 8 commit. But on remote branch some other developer pushes some changes. And you want to get them and re-apply your changes on top of that. In order to do that you can run this command when you are in your someNewFeature
branch:
git pull --rebase origin someNewFeature
Upvotes: 1
Reputation: 8237
Have you tried a simple git rebase someNewFeature origin/someNewFeature
Upvotes: 1