Reputation: 5764
A developer in my team committed his changes to the wrong remote repository. I want to remove what he pushed to this repository on the remote repository. I don't want to change anything locally.
Therefore how can I:
List the commits on the remote repository branch so that I can see which commits that have been pushed need to be removed.
Remove each of these commits on the remote repository branch so that I can go back to the commit before he pushed his changes.
I am not sure if "removing" is the correct process or if it is meant to be "revert" but in the end I need the remote repository branch to be back to where it was before he pushed his changes.
Upvotes: 3
Views: 440
Reputation: 129526
Mark where that branch was last by
git tag original-master origin/master
inspect what you get from the server:
git fetch
git log --all --graph
or
gitk --all
if your tag still makes sense that that's where the remote branch should be, force push that up:
git push -f origin original-master:master
if it's another commit, push that commit as the master:
git push -f origin <some SHA1>:master
clean up:
git tag -d original-master
update your tracking branches since the fix:
git fetch
This assumes "master" is the branch in question. Replace "master" with the proper branch name if it's another one.
Upvotes: 5