Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

How do I revert a pull request?

roi_holtzman May 17, 2018

I've made a branch on one machine (call it the 1st machine) and then pushed my commits to the online server. Then I performed a `pull` request from a 2nd machine. On the 2nd machine I only had one master branch. I got that all the changes in my new branch are merged into my master branch. I did not expect this. I wanted to have the new branch on the 2nd machine as well.

I now see that I should have done "fetch" instead of "pull". The question is, how do I invert this pull request?

BTW, I saw the answer here, but I don't see a `Reset...` option when clicking on the last commit of master.

1 answer

1 accepted

1 vote
Answer accepted
Mikael Sandberg
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
May 17, 2018

You have to click on the commit you want to reset to, then you should see the option. You can also reset from the command line by using git reset --hard <commit to reset to>, or if you have not pushed your changes back to the remote master, you can use git reset --hard origin/master

In order to see new branches created on the remote you need to do a fetch in order to update your local repository. Doing a pull will not fetch any new branches, it will only fetch changes made on your current branch and then merge it.

roi_holtzman May 17, 2018

@Mikael Sandberg Thanks. Do I need to choose the "hard" option when choosing to reset? It will not delete what I have on the server, right?

Mikael Sandberg
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
May 17, 2018

Hard will reset the index and working tree, meaning if you have made any local changes on master that has not been pushed to your remote, those will be deleted. 

roi_holtzman May 17, 2018

@Mikael Sandberg I did this, and indeed it works. In the history view I still see the latest commit I did by mistake, but the files are reverted.

Now, I did fetch, but I don't see the new branch in my 2nd machine. Why is that?

Mikael Sandberg
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
May 17, 2018

Did you check under Remotes > Origin?

Sourcetree.png

You can also run git branch -r to list all the remote branches that your local repository knows about.

roi_holtzman May 17, 2018

@Mikael Sandberg I see it under Remotes > Origin.

How do I put it in my local stuff?

Mikael Sandberg
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
May 17, 2018

Right-click on it and select Checkout origin/..., that will bring up the checkout branch screen and from there you just select OK and it will create a local copy of the branch and setup the link to the remote branch.

roi_holtzman May 17, 2018

@Mikael Sandberg Got it!

Thanks a lot!!

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events