0

It's silly really, I made a pull request yesterday on branch_A to master. Many files were changed and I don't want to add more to it. I switched to a new branch from branch_A to branch_B. I added the files I wanted to commit, and pushed from branch_B.

On Github, if I want to merge this commit to master, it shows that both the pr I made on a separate branch and this new commit are together. I did not want to push this commit to my previous pull request. I thought since I was on a new branch, that it would create a way to make a new pull request.

Should I remove the commit and try a different way? Should I merge the commit and pr? Should I just submit the pull request as is? Should I try to push this commit to Branch_A instead of master? There are many questions.

Here's a look at the cli steps:

  • git branch -vv (master, branch_A)
  • git checkout -b branch_B
  • git add .
  • git commit -m"something cool"
  • git push origin branch_B

Any help would be great!

Jordan
  • 117
  • 1
  • 1
  • 11

1 Answers1

0

switched to a new branch from branch_A to branch_B

Creating branch_B whilst having branch_A checked out resulted in branch_B being based off of branch_A:

Tree 1

branch_B  // <- subsequent commits to branch_B
|
branch_A  // <- commits to branch_A
|
|
master

I did not want to push this commit to my previous pull request.

If I've understood you correctly you'd rather have done this:

Tree 2

branch_B  // <- commits to branch_B
|
|   branch_A  // <- commits to branch_A
| /
|
master

Here the commits to branch_B are applied to master and do not include the changes to branch_A.

To go from Tree 1 to Tree 2 you will need to do a rebase*:

$ git checkout branch_B
$ git rebase master
$ git push -f # WARNING: this command will re-write the git history for this branch.
              # If other's use this git repo, especially if they have checked out `branch_B` locally, they should be consulted first.

*With the rebase command, you can take all the changes that were committed on one branch and replay them on a different branch.

tjheslin1
  • 1,378
  • 6
  • 19
  • 36