Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

How do you revert?

Tyler Mittan August 13, 2018

Hi,

 

I accidentally pushed something to the Master branch (I really wish there was a safeguard.. Of course I should be more careful, but the whole point of a safeguard is in case you aren't being too careful).

 

I would like to revert it. When I tried to revert it, I got some error message. Unfortunately I don't have that message, but now there is a new message ahead of my commit that says uncomitted changes (I am using SourceTree). When I try to click revert, it now gives me the error:

 

error: Reverting is not possible because you have unmerged files.

hint: Fix them up in the work tree, and then use 'git add/rm <file>'

hint: as appropriate to mark resolution and make a commit.

fatal: revert failed

Could someone please help me with this?

1 answer

0 votes
Mikael Sandberg
Community Champion
August 13, 2018

Hi Tyler,

Welcome to the Atlassian Community.

Have you pushed your merge to the master branch back to Bitbucket? Or is it just locally in your repository?

Tyler Mittan August 13, 2018

I don't think I did that (I am not quite sure how to do that either.. I just started using bitbucket and SourceTree). As soon as I saw that it was the Master Branch, I immediately went to SourceTree , Google'd around, and did this revert method.

However, when I sign into bitbucket, it's clearly there as a commit.

Like Ashleigh Parsons likes this
Mikael Sandberg
Community Champion
August 13, 2018

Okay, so if you see your commit in Bitbucket then your changes have been pushed there.

The changes you pushed to your master branch, where they done on a separate branch that you merged into master or was it all done one master? In order to clear out the errors you currently see I would to a git reset to get back to the same commit Bitbucket knows about. In Sourcetree click on the commit that you want to revert, right-click on it and select Reset current branch to this commit and select Hard as the mode to use

Sourcetree.png

This should remove any uncommitted changes. You can now try and do a revert to roll back your changes on master.

Tyler Mittan August 13, 2018

Okay, this won't mess up anything that was done before I made that mistake? Someone else is the primary developer and he's done a lot of work on the Master.

Were my changes done on a separate branch? I have my own branch and I never did anything with merge. I was using Visual Studio and I committed to the Master branch by accident.

I just want to make sure none of his work gets messed up if I do this (he has his own branch and makes all of the changes to the master branch).

Mikael Sandberg
Community Champion
August 13, 2018

As long as you reset back to the commit you made you should be fine. An example:

Sourcetree.png

In this example I uncommitted changes and I want to reset my branch to the commit that my remote copy of the branch knows. It will basically delete my uncommitted changes and the commit called Testing something. Note that this is all done locally and Sourcetree will not push anything back to Bitbucket since you are not committing anything. Once you are back to the commit you made, you can do a revert of it. Your other option is to clone the repository again and then do a revert, that will have the same effect.

Tyler Mittan August 13, 2018

Okay, that makes sense, but what I am seeing is a little confusing..

 

The option it gives me is to Reset to my branch rather than reset to the previous Master branch.. 

So it says "Reset TylerBranch to this commit"

Shouldn't it say reset "Master" to this commit? From there I can try to revert?

Mikael Sandberg
Community Champion
August 13, 2018

Correct, you should be on the master branch when you do the reset.

Tyler Mittan August 13, 2018

Do I need to get on that using a different email address? I am not seeing any way that I can be on the master branch on Sourcetree

Mikael Sandberg
Community Champion
August 13, 2018

No, just double-click on the branch or right-click on it and select Checkout master...

Tyler Mittan August 13, 2018

'.png
This is what I am getting.

Tyler Mittan August 13, 2018

I think I figured it out. Sorry for being a pain and thanks for putting up with me!

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events