1

I'm new to GitHub pull requests and wondering if this would work.

Right now I branch off master, make changes and commit periodically, then at some point I'll checkout master again and run git pull to get the latest from origin.

Next, I checkout my branch and call git rebase -i master to apply those changes and to make sure I don't have any conflicts when the time comes to merge back to master.

I'll go through that cycle periodically while working. When I'm ready to integrate to the master branch I checkout master and call git merge <my branch> then push to the repository.

But with pull requests do I need to take that last step? Instead, can I submit a pull request on my branch and then on GitHub apply it to master?

(I'm also open to improvements on my existing workflow, if any are apparent.)

larryq
  • 15,713
  • 38
  • 121
  • 190

2 Answers2

1

Yes, you certainly can submit a pull request on your branch and merge it to master in GitHub.

It will be best to do this when working with a Pull Request on a public repo where your changes will be reviewed before being merged back into the master of the repo.

Jason Ng PT
  • 176
  • 6
1

with pull requests do I need to take that last step? Instead, can I submit a pull request on my branch and then on GitHub apply it to master?

  1. you should always submit a pull request from a branch that you have push to your GitHub fork.
  2. You even can rebase that branch on top of master, git push --force that branch to your fork, and your existing pull request will be updated. Automatically

The only merge of your branch to master will take place in the original repo by the main maintainer, should he/she chose to accept your pull request.

See more with couple of tips for pull requests.

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Thanks for the tips...ah, in the instances where I haven't forked, just branched, can I still do a pull request from the branch? – larryq Jan 17 '14 at 17:30
  • 1
    @larryq pull request, as in "GitHub pull request", is only done from a fork at the GitGub server. "Just branch" means you have cloned a repo of yours (to which you can push back to) and you will have to merge your branch locally, pushing the resulting merge commit. But that is different from a "pull request". – VonC Jan 17 '14 at 17:32
  • I thought that as well, but when I push my local branch to GitHub (via git push --set-upstream origin ) I can create a pull request on GitHub for it. I thought that was unusual, can you think of why that would work? I looked in GitHub under my account and I have two forks, neither for this particular repo. – larryq Jan 17 '14 at 18:43
  • @larryq see http://programmers.stackexchange.com/a/178489: it can help for monitoring how a branch progress before merging it back to master. You benefit from all the features around PR (Pull Request) for that branch. – VonC Jan 17 '14 at 20:10