Reputation: 1621
I remember doing something like committing my changes(on my feature branch) and merging with a remote branch (not master). Then in order to make sure my commit came on top of the merge commit I rebased the last two commits and changed the order. I pushed these changes and others committed on top of this as well.
Now, what happened is that a few of the merge commits were picked with a different commit ID and now when I create a pull request it shows up as mine. I can understand this is because the same changes are in my branch from a different Commit ID so it shows up as someone else authored and I committed but the changes don't show up in the files tab since the changes are already there.
This is my reflog
HEAD@{12}: rebase -i (finish): returning to refs/heads/my_branch_name
NEW COMMIT ID HEAD@{14}: rebase -i (pick): Messed up merge commit
NEW COMMIT ID HEAD@{15}: rebase -i (pick): Messed up merge commit
NEW COMMIT ID HEAD@{16}: rebase -i (pick): Messed up merge commit
NEW COMMIT ID HEAD@{17}: rebase -i (pick): Messed up merge commit
And a few commits were added but others and me after this and this branch are used by a couple of other people. I am not sure how to fix this.
One idea I can think of is to revert all these commits but that will create another 4 more commits.
Is there any way I can deal with this?
Upvotes: 0
Views: 1181
Reputation: 38714
The first thing you need to do is undo what you've done so you can do it right. You didn't mention what branch you're working with, so I'll assume it's master
.
reflog
and find the commit right before you started messing things up.git fetch origin master
git checkout -f master origin/master
To save the "messed up" master branch under a new branch name, do:
git branch messed-up-master
git push -u origin messed-up-master
Now that it's saved, continue fixing as follows:
git reset --hard HASH
where HASH is the hash that you saved from the reflog
.
git push -f
Now you're back where you were before the messup. Then work on figuring out the right way to do what you want.
Upvotes: 2