Reputation: 1114
I have a branch called dev
where I put some code for ejb changes and committed it to github, but the code didnt work, so to preserve the work, I created a branch out of dev
called ejb_change
and pushed to github.
I reverted the code in dev
branch and committed more codes in dev
branch and now I want to merge the ejb_change
branch to dev
branch.
But when I do a git merge ejb_change
/ raise Pull Request, git is telling there are no change to merge. I am not able to understand
How do I put the ejb_change
changes on top of current dev
branch
Upvotes: 0
Views: 1802
Reputation: 95
when you say
I reverted the code in dev branch and committed more codes
you mean that you commited some code undoing your changes? Or did you revert git history to a previous state? If you just commited a code undoing your changes, than the commits from ejb_change are already in dev and there's no merge.
Upvotes: 0
Reputation: 120
I had a similar problem, also caused by a revert
. The way I fixed it was by making a git reset --hard <commit hash>
on dev
branch with commit hash
being the commit before the wrong code.
A->B->C, if B is the wrong code, C is it's revert, so use the hash of A.
This solution does require a force push
once the dev
history is changed because of the reset
Watch out with the
--hard
as it will remove any changes after the selected commit, so do this only when you are sure you don't need the commits that will be reset
After that your pull request should work normally.
I guess there are better solutions but that's the one I know of.
Upvotes: 0
Reputation: 30307
If your reverted (like, used git revert
), then ejb_branch is pointing to a revision that is part of the history of dev... and therefore if you try to merge ejb_change into dev, git will tell you that there's nothing to merge there.
If this is the case (I know this is the case because you already said so) then you could try either cherry-picking the original revision that you reverted (not sure if it will work, because the revision if part of the history of current branch)... or reverting the reversal revision... not elegant, but should work.
Upvotes: 3