0

My friend made a branch user and while I was on my master I did git pull origin user and now that branch has been merged to my master.

I realised it only after many other changes and commits, but we decided not to implement that branch any more. How do I remove those files from my master and make my local master the same as the Github one?

I tried git reflog but I'm not sure what information I get there, many commits are being repeated. My git status shows my branch is 6 commits ahead.

Tom Bom
  • 1,589
  • 4
  • 15
  • 38
  • Assuming you didn't rewrite history, you can do a simple `git reset HEAD^`. – jhpratt Dec 13 '17 at 08:06
  • 1
    Possible duplicate of [How to revert Git repository to a previous commit?](https://stackoverflow.com/questions/4114095/how-to-revert-git-repository-to-a-previous-commit) – jhpratt Dec 13 '17 at 08:11
  • I edited the question a bit, I stashed some changes but never committed them. Still `git reset HEAD^` – Tom Bom Dec 13 '17 at 08:13
  • Are you still in the process of merging? If that's the case, just abort. If not, what's the problem? Just delete the stash. – jhpratt Dec 13 '17 at 08:17
  • Is it done by `git stash clear`? – Tom Bom Dec 13 '17 at 08:21

3 Answers3

1

I did git reset --hard origin/master and it resolved all of my problems.

Tom Bom
  • 1,589
  • 4
  • 15
  • 38
0

Reset the not commited changes with a git reset --hard HEAD More infos are here How do I use 'git reset --hard HEAD' to revert to a previous commit?

Mario Naether
  • 1,122
  • 11
  • 22
0

A) Your uncommitted changes are still there, like you said, you can stash them and add them later.

B) Verify you're on the right branch and do git reset --hard, that will revert all changes back and you'll be on the HEAD of the branch

GuyKhmel
  • 505
  • 5
  • 15