0

I am facing problem in the creating a branch from upstream. Let me explain my issue: I forked one repo to work on it.

I made some changes and did 3-4 commit/push into the branch which is master. Since those changes don’t need to merge(pull) into the upstream branch. Then I have to discard those commit and sync with the upstream branch. How can I remove those commit to my branch?

Can I create a new branch which is based on current head of upstream?

BartoszKP
  • 34,786
  • 15
  • 102
  • 130
CrazyC
  • 1,840
  • 6
  • 39
  • 60

1 Answers1

0

From what you have said it sounds like you have made some changes to your local master and want to discard them and reset to upstream master.

This seems much the same as this question: Behavior of "git reset --hard" and a similar answer applies.

You can, as mentioned in the comments, delete your fork and fork again (since you have no work you need to save), but this could be a problem if you have other branches in your local repo that you need to keep. Alternatively you can also reset your local master by running the following command:

git fetch upstream master git reset --hard upstream/master

This will reset your local master to be the same as the upstream master.

  • You are right. Actually I had seven commit. I tried git reset --hard HEAD~7 But once I did pull it pulled out my last 7 changes also. – CrazyC Nov 01 '18 at 16:16