Reputation: 499
I had one master branch, then decided to work on new feature and created branch for it. After I did some stuff I've pushed it to remote. Then I switched to master and continued work on it made some feature. And the I tried to push it to remote and got message that I have to pull first as far as:
"hint: Updates were rejected because the tip of your current branch is behind hint: its remote counterpart."
Inspecting pull gave me info that remote I'm trying to push to contain all changes from "feature" branch. So first guess -- I've pushed to wrong remote branch. But I see featured branch in remotes as well(may be latter I've pushed to right one)
I'm the only one contributor so I have all power to revert anything and etc. What is best strategy to revert remote branch from last push(I use bitbucket)?
Upvotes: 0
Views: 233
Reputation: 1573
If you haven't pulled down the remote changes yet, you can just do a force push:
git push origin +master --force
This will set the state of the remote master branch (and only the master branch, which is what the + is for) to the state that your local branch is in.
If you've already pulled down the changes and merged/rebased then you'll need to get your local branch into the state you want the remote to be in. You can do this with a reset:
git reset --hard <hash of commit you want to be last on master>
Then do the force push.
Upvotes: 1
Reputation: 234
Assuming that you have already committed all the changes, use the following commands:
git checkout master
git reset --hard <commit_id_you_wish_to_reset_your_master_to>
git push --force origin master
Upvotes: 1