1

When I forked the project initially and set up my env I had this.

> git branch -a

remotes/origin/HEAD -> origin/master
remotes/origin/master
remotes/upstream/master

I do not have "push" permission to the upstream project. I must send pull requests from my fork.

A week later a new branch was created for work on a specific enhancement to upstream. The team may be working from this branch for many weeks.

remotes/origin/HEAD -> origin/master
remotes/origin/master
remotes/upstream/new-project-feature
remotes/upstream/master

What is the appropriate way for me to setup and submit code to this branch? This is what I have done. Was it the proper thing to do?

git branch new-project-feature
git checkout new-project-feature
git rebase upstream/new-project-feature
.. code changes
.. commit
git push origin HEAD:new-project-feature
.. go to github and send the pull request.

How does the parent project know to merge the pull request to its new-project-feature branch?

tshepang
  • 12,111
  • 21
  • 91
  • 136
user976831
  • 61
  • 1
  • 1
  • 4

1 Answers1

0

The idea behind a pull-request is:

  • you work on a small enhancement that you would like to see merged into the upstream branch
  • you push that enhancement to your fork (origin), and make the pull request from there

fork

BUT:

You should make that enhancement in a dedicated branch, not in the target branch.
That means, not in master or in new-project-feature: those are "target" branches which, in your fork, are there to mirror the upstream repo, to "remote track" upstream/master or upstream/new-project-feature.

So you should make one or several branches, each one for a small change you want to contribute to new-project-feature, push that one little branch "small_change", and make a pull request to upstream/new-project-feature.

You can regularly pull upstream, updating your local new-project-feature with the latest of upstream/new-project-feature.
You can then rebase your "small_changes" branch on top of the updated new-project-feature branch, and go on working on it.

Note that if new-project-feature changes in upstream after you already make your pull request from the fork, all you need to do is:

  • fetch and update locally the new-project-feature branch
  • rebase your small_change branch on top of new-project-feature
  • check that everything still works
  • git push --force origin small_change

The last forced push will automatically update your pull request: you won't have to do a second pull request.
See more at "How to do a Github pull request?".

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250