1

Please find below steps that I did on forked repo:

  1. I have created the fork of famous OSS project on Git Hub
  2. Done some changes, raised PR from master branch from forked repo to upstream, the PR is approved and merged with rebase/squashed commits
  3. Now, I want to work on another feature, unfortunately after doing git merge upstream/master, the master in forked repo is ahead of upstream due to merged commits

To reset fork, I am doing:

git reset --hard upstream/master  
git push origin master --force 

If I would have created feature branch and PR from that branch, deleting that branch would be easy.

However, since it is done from master branch, does it affect my first PR or is it safe to reset fork after submitting PR?

userda
  • 595
  • 5
  • 15
  • You can create a new branch on where master is before doing the reset you show above. That'll be your feature branch. – Mad Physicist Jul 14 '18 at 03:21
  • Can't I reset master branch? – userda Jul 14 '18 at 03:24
  • Yeah, but I'm assuming you want to mark your changes with a branch first. – Mad Physicist Jul 14 '18 at 03:26
  • Also, why are you working off master in the first place? – Mad Physicist Jul 14 '18 at 03:27
  • Yes, I realized later that to better use feature branch. Now, all I want to reset fork (master branch) without affecting completed PR – userda Jul 14 '18 at 03:30
  • I'm not sure I fully understand. You have three repos: upstream is the project, origin is your fork on GitHub, and local is your clone of origin. You made a squashed commit on local/master, pushed it into origin/master, whence it got merged into upstream/master. What is the actual problem? – Mad Physicist Jul 14 '18 at 03:37
  • Could you draw a little sample history graph perhaps? Something like https://stackoverflow.com/a/51270796/2988730. – Mad Physicist Jul 14 '18 at 03:41

1 Answers1

1

since it is done from master branch, does it affect my first PR?

No, your first PR was approved and merged.

or is it safe to reset fork after submitting PR?

Yes, you can force push master.
And then make a dedicated feature branch for your new PR.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250