Github branch help

I have a project using pull requests, and I’m trying to create a branch (branch1), delete 3 files, and create a pull request.

Then without merging the code to master, I want to create another branch (branch2) with the 3 files from branch1 missing from the code, delete 1 more file, and create another pull request.

How would I do this?

I was thinking to create two branches from master but then I have to delete the 3 files from both… and it will be in both pull requests. I just want 3 files deleted in 1 pull request and 1 file deleted in the other pull request.

I might not be following you here but can’t you just create branch 2 from branch 1?

Is that possible? I’ve never done it.

Yes, if I understand what you are asking. You can have the starting point of a new branch be any current branch (not just master/main).

Create branch 1 make the changes and commit them, stay on branch 1 (checked out) then create branch 2 with branch 1 as the starting point.

I gave it a try but for some reason this happened which I was trying to avoid:
branch1 PR#1 has 1 commit deleting 3 files
branch2 created from branch1 PR#2 has 2 commits, 1 commit deleting 3 files and 1 commit deleting 1 file (I don’t want the deleting 3 files to be here)

I am looking for the following to happen, not sure if it’s possible without merging PR#1 to master first:
branch1 PR#1 has 1 commit deleting 3 files
branch2 created from branch1 with the 3 files deleted but PR#2 only has 1 commit deleting 1 file

If I’m understanding you correctly you have a time issue here, this isn’t really just git, there’s a logical problem with what you’re trying to do

b1 has three files removed, b2 has the three files. b2 comes after b1 in time. b1 gets merged to main. Now those three files aren’t there, b2 is based on that so if you bring b2 into sync, those three files aren’t there either.

Is that about right?

Edit: if I’m understanding you right, the logical thing to do would be to add the three files back in the first PR for b1, ie add a new commit, if it hasn’t been merged yet. Then PR1 can be approved, merge b1 to main and delete b1. Then merge main changes to b2 to make sure it’s in sync, then approve PR2, and merge b2 to main and delete

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.