Reputation: 35988
I have a PR up on github and I accidentally merged master into my PR and pushed it. Now the PR shows way more files changes than the ones just changed by me because the master was merged in. How can I just delete the previous to merge master commits from the PR?
I tried doing git revert <hash>
and now the PR commits look like this. However, the total number of Files Changed is still incorrect. It is showing files that I didnt' change.
The PR commits look like this:
My good commit
Merge branch 'master' into this-prbranch
Revert "Merge branch 'master' into this-prbranch"
Upvotes: 4
Views: 6536
Reputation: 37287
You can first locate the merge commit with git log
, take down its SHA.
Then, revert your tree to the point before it:
git reset --hard abcdef8~
(apparently you should replace abcdef8
with the SHA of the merge commit)
And force-push the reverted tree:
git push -f
Why does git revert
not work as expected?
From git-revert(1)
:
Given one or more existing commits, revert the changes that the related patches introduce, and record some new commits that record them.
Upvotes: 5
Reputation: 165
git log
to see all commitsgit rebase -i <commit hash>
to rebasegit push -f
Upvotes: 0