Author

Topic: github question on contributing to bitcoin - unsure about creating a PR (Read 181 times)

member
Activity: 86
Merit: 26

No, you can't push on upstream, you don't have the permissions to do it so.

You just push your branch to your github repository, doing git push origin, and create a PR (you'll get a beautiful "Compare & pull request" showing on your fork repository  page on github)

Code:
$ git push origin
Counting objects: 13, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (13/13), done.
Writing objects: 100% (13/13), 4.17 KiB | 4.17 MiB/s, done.
Total 13 (delta 9), reused 0 (delta 0)
remote: Resolving deltas: 100% (9/9), completed with 8 local objects.
To github.com:mycroft/bitcoin.git
 * [new branch]          new_feature -> new_feature

Got you. Thanks
full member
Activity: 198
Merit: 130
Some random software engineer
then I checked out the upstream/master
$ git checkout upstream/master
$ git checkout -b

and added my changes again.

That's the same thing, and you got it right !

Unfortunately the last update killed my changes as the feature I wanted to add relies on a feature which was removed 2 days ago....
So I cannot continue to check if creating a pull request would work the way I did now.

Sorry for that... that is life of opensource Smiley

Maybe you can tell me if I'm on the right track with my steps above so I can do it correctly when I have another change I want to contribute?
What would be the correct next steps to create a pull request?

$ git commit
$ git push -u upstream/master

Would I see then the upstream branch in my github repository to be able to create the pull request from there?

No, you can't push on upstream, you don't have the permissions to do it so.

You just push your branch to your github repository, doing git push origin, and create a PR (you'll get a beautiful "Compare & pull request" showing on your fork repository  page on github)

Code:
$ git push origin
Counting objects: 13, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (13/13), done.
Writing objects: 100% (13/13), 4.17 KiB | 4.17 MiB/s, done.
Total 13 (delta 9), reused 0 (delta 0)
remote: Resolving deltas: 100% (9/9), completed with 8 local objects.
To github.com:mycroft/bitcoin.git
 * [new branch]          new_feature -> new_feature
member
Activity: 86
Merit: 26

What did I miss or how can I create a pull request with only the changes done in the topic branch and not everything I have done in the master branch?


When you do a pull request, it will ask for the upstream project to pull the whole branch contents & do a diff against upstream branch. This includes your commits in the current branch, but also all commits that are in the history in the branch.

So, if history on upstream is A -> B -> C, you clone this, then create a feature D you push in master in your own repository, then create a branch from D and commit E (you'll get A -> B -> C -> D -> E in this branch), the pull request will make a diff between upstream history (A -> B -> C) and your current commit log (A -> B -> C -> D -> E), and not only the commits you exclusively made in your branch.

What you want to do is clone the upstream repository and commit your new feature by creating a branch from upstream's master branch, not from your master branch.

Thank you for your quick response.

I had to lookup what an upstream repository is, but I think I found out how it works.

I did the following

$ git remote add upstream https://github.com/bitcoin/bitcoin
$ git fetch upstream

getting the last changes from upstream to be up to date
$ git checkout master
$ git merge upstream/master

then I checked out the upstream/master
$ git checkout upstream/master
$ git checkout -b

and added my changes again.

Unfortunately the last update killed my changes as the feature I wanted to add relies on a feature which was removed 2 days ago....
So I cannot continue to check if creating a pull request would work the way I did now.

Maybe you can tell me if I'm on the right track with my steps above so I can do it correctly when I have another change I want to contribute?
What would be the correct next steps to create a pull request?

$ git commit
$ git push -u upstream/master

Would I see then the upstream branch in my github repository to be able to create the pull request from there?

I think I need to do some experimenting on a github test project as well to see how everything works.


Edit: did not see your last edit before posting my comment.
But it looks like I found the correct way how to do it. I think I just did also some unnecessary steps.

I will do some tests on a test project to make sure I understood everything correctly.

Thank you so much!
full member
Activity: 198
Merit: 130
Some random software engineer

What did I miss or how can I create a pull request with only the changes done in the topic branch and not everything I have done in the master branch?


When you do a pull request, it will ask for the upstream project to pull the whole branch contents & do a diff against upstream branch. This includes your commits in the current branch, but also all commits that are in the history in the branch.

So, if history on upstream is A -> B -> C, you clone this, then create a feature D you push in master in your own repository, then create a branch from D and commit E (you'll get A -> B -> C -> D -> E in this branch), the pull request will make a diff between upstream history (A -> B -> C) and your current commit log (A -> B -> C -> D -> E), and not only the commits you exclusively made in your branch.

What you want to do is clone the upstream repository and commit your new feature by creating a branch from upstream's master branch, not from your master branch.

Edit: To be more specific (sorry, I had to go AFK):

Code:
$ git remote -v
origin  [email protected]:starmyc/bitcoin.git (fetch)
origin  [email protected]:starmyc/bitcoin.git (push)

$ git remote add upstream https://github.com/bitcoin/bitcoin

$ git remote -v
origin  [email protected]:starmyc/bitcoin.git (fetch)
origin  [email protected]:starmyc/bitcoin.git (push)
upstream        https://github.com/bitcoin/bitcoin (fetch)
upstream        https://github.com/bitcoin/bitcoin (push)

$ git fetch upstream

$ git checkout -b new_feature upstream/master
Branch new_feature set up to track remote branch master from upstream.
Switched to a new branch 'new_feature'

# Commit your changes here
# And do the PR against this branch
member
Activity: 86
Merit: 26
I was missing a small, let's say feature, in the current bitcoin-qt version. So I decided to implement this by myself.

As I never contributed to an OSS before I did some research on how to do that correctly.

Starting point was the CONTRIBUTION document from the bitcoin repository https://github.com/bitcoin/bitcoin/blob/master/CONTRIBUTING.md.
My missing knowledge there was basically the correct use of git / github with branches, remote repositories, merging and pull requests.

I learned about that and I'm quite confident that I understood all those stuff.

I already did
  • Fork the bitcoin/bitcoin repository to my github account
    done on github.com
  • Frequently created pull requests from bitcoin/bitcoin to my forked repository to stay up to date
    done on github.com by browsing to bitcoin/bitcoin repository -> clicked "New Pull request" -> clicked compare across forks -> changed the "Base fork" to my repository -> created the pull request and merged it
  • cloned my forked repository to my build environment
    $ git clone https://github.com//bitcoin.git
  • created a topic branch
    $ git checkout -b
  • made my changes
  • commited my changes and pushed the local topic branch to my forked repository
    $ git commit
    $ git push -u origin

Now comes the part where I'm uncertain if I did everything correct or if I'm missing something.

On github I browsed to my bitcoin fork, selected my pushed topic branch and clicked the "New Pull request" button.

There I see the comparison from bitcoin/bitcoin to my_fork/topic_branch. The suggested title for the pull request by github is my last commit message from my topic branch. So far so good.

But I expected to see only my changes I made within the topic branch, but additionally I also see all the changes from my previously pull requests from bitcoin/bitcoin which I merged to my master branch.
Of course I don't want to have those changes in my pull request back to bitcoin/bitcoin.

I did not see anything on github which allow me to select only my last commit to be in the pull request.

What did I miss or how can I create a pull request with only the changes done in the topic branch and not everything I have done in the master branch?

I would appreciate any hints on how to solve this issue.

Thank you in advance.
Jump to: