I have created a feature branch and made somes commits on it
Now I would merge my feature-branch
to develop
but I would not take the last commit.
How can I merge before penultimate commit ?
I have created a feature branch and made somes commits on it
Now I would merge my feature-branch
to develop
but I would not take the last commit.
How can I merge before penultimate commit ?
You can make a backup, undo the unwanted commit on your branch, then push.
git branch <backup_feature> <feature-branch>
git checkout <feature-branch>
git reset --hard HEAD^
git push origin HEAD
and you'll have a backup of the last (unwanted) commit on branch <backup_feature>
.
If the last commit was really unwanted, just keep on working on your branch, it's gone.
If, in the other hand, you need it back on your branch after the push, just
git merge <backup_feature>
It'll be a transparent fast-forward (as long as you don't commit again on the branch before merging this commit back in. If you do merge it back later on, you might have to resolve conflicts)
Recap of what's in comments below : OP did already push the feature branch with the unwanted commit to remote. Suggestion has been to push with --force
to update the remote ref and, subsequently, the associated pull request.