4

Okay ... here's the situation:

  • I forked a repository
  • I made a new branch. the branch name is configs
  • I committed a few changes and made pull request #1
  • Pull request #1 is still being reviewed and has not been merged on the base repository
  • I made a few more changes. still in the configs branch. but this new change does not affect previous changes (different files)
  • I made a new commit and of course it is still in configs brach
  • When I look at github, this new commit will go to the previous pull request, pull request #1.

Well, my question is "How do you make this new commit as a new pull request or lets say pull request #2 but still in the same brach?"

thanks.

Romain Valeri
  • 19,645
  • 3
  • 36
  • 61
Don Nisnoni
  • 104
  • 9
  • Possible duplicate of [How to open multiple pull requests on GitHub](https://stackoverflow.com/questions/8450036/how-to-open-multiple-pull-requests-on-github) – Rumid Sep 17 '19 at 11:04

1 Answers1

4

Put your second commit on another branch

# now

A---B---C <<< main-line
         \
          D---E <<< configs

# target

A---B---C <<< main-line
         \
          D <<< configs
           \
            E <<< configs-plus

To achieve that, step by step :

# start from branch configs
git checkout configs

# Create the new branch (by default, it'll point at HEAD, so configs)
git branch configs-plus

# reset current branch (still configs) to last commit
git reset --hard @^

# finally, push (--force (or -f) needed because history has been rewritten)
git push -f origin HEAD

Then create a new PR configs-plus > main-line. The first PR will have been updated by the force push to remove the second commit.

Romain Valeri
  • 19,645
  • 3
  • 36
  • 61
  • thanks it works ! we can also use git stash and git stash pop to take any working changes to the new branch. – Karambit Jun 25 '21 at 18:32