3

I just did git pull origin branch accidentally and now I have all these changes merged into master

I tried reverting the commit w/ github for mac and got this error:

fatal: Commit d0fbfb0f7d3ea8.. is a merge but no -m option was given. 

2 Answers 2

6

Assuming you have not committed anything on top, git reset --hard HEAD^ will do what you want. HEAD^ refers to the first parent of the current commit, which is the one you want to reset back to.

A "hard reset" will set the current branch and the work tree to point to whatever you tell it to, discarding anything else (notably uncommitted changes). This is a BIG hammer, so be careful.

Sign up to request clarification or add additional context in comments.

1 Comment

will HEAD^ work? the branch i merged had multiple commits, so i need to go like 10 commits back to get to where i was before..
1

You can do:

git reset --hard ORIG_HEAD 

After a pull ( merge), ORIG_HEAD will point to the previous HEAD.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.