0

I forked a project (i.e., MainProject:main ) into Jay:main. I created a new branch Jay:feature from Jay:main. In MainProject:main I created a pull request using Jay:feature.

After many merges done to MainProject:main, my PR has a conflict that need to be addressed before it can be merged.

I pulled the lasted changes from MainProject:main into Jay:main so both branches are at sync. While on Jay:feature, I executed git rebase main to ensure all the changed from Jay:main make it to Jay:feature in order to resolve the conflict.

Then I did git commit followed by git push. Unfortunately, my PR now has way too many file which should not be part of the PR.

How can I get only the diff files into the PR?

I thought I would just create a new branch using the difference between Jay:main and Jay:feature. Here is what I did git checkout feature then git reset --mixed so I can stage the difference between the two branches.

Now, I am not sure how would I commit my staged files into a new branch? Or, is there a better way to make sure my PR only include the stages files?

Jay
  • 1,168
  • 13
  • 41
  • You're starting from a wrong / bad position here: *every* commit holds *every file*. You don't just commit changed files, you commit unchanged files as well. What you see when you make a GitHub pull request is the set of changes to *all* the files between *all* the commits involved in the PR. But what's not clear here is why, after updating your fork and rebasing, you're seeing so many changes, because the rebase operation works the way you would want here, converting snapshots (commits) to changes to apply to the new updated snapshots to make new snapshots that only have your changes. – torek Sep 16 '22 at 03:12
  • I realize this is very confusing - it's hard to fit an accurate description into a comment. The bottom line is that from your description, you've done this right, so there's some glitch in your description. If you can provide a [mre] or links to the actual repositories involved, someone can perhaps use that to figure out what's going on. – torek Sep 16 '22 at 03:14
  • @torek thank you for your help. I ended up doing `git checkout -b newBranch` then `git add .`, `git commit -m”message”` finally `git push`. Unfortunately I had to create a new pull request from newBrach. I was hoping there would be a way to fix existing PR – Jay Sep 17 '22 at 04:27

0 Answers0