Suhas Deshpande
Suhas Deshpande

Reputation: 725

How can I make separate pull-requests for each commit in same branch?

I have commit 'a' pushed to remote branch. I send a pull request for that specific commit. Now before that commit is merged, I pushed another commit. I want to treat these 2 commits as separate pull request and I don't want to create a new branch just for that. Is there a way to do it?

Upvotes: 2

Views: 1462

Answers (2)

Bura Chuhadar
Bura Chuhadar

Reputation: 3751

Normally you should create a branch for your each pull request. However you can achieve like this:

git push <remote name> <commit hash>:<remote branch name>

//This will push all commits up to and including the specified commit.

//An example solution for your problem:
git push origin dc5ea3b083a6e6b08f0b3742f9fe55b3:myfirstremotebranchforpullrequest

git push origin 985ccb86d2a8b61e145a79206c599b76:mysecondremotebranchforpullrequest

Upvotes: 2

o11c
o11c

Reputation: 16056

Since each commit includes a reference to its parents, you must create separate branches in order to not include that information.

git cherry-pick on each new branch will probably be the easiest way to do this, although git rebase -i would work too.

You don't need to fear branches with git. Unlike, say, subversion, branching in git is cheap and easy, and they can be cleaned up once the PR is merged.

Upvotes: 3

Related Questions