6

I want to submit my first (ever) GitHub pull request and am running into some difficulty doing so.

According to this article I must first create a branch. So I:

  • git clone https://github.com/theuser/therepo.git
  • git branch mybranch
  • git checkout mybranch
  • Make my changes
  • git commit -a -m "Closes theuser/therepo/#100"

My thinking here (please correct me if it was wrong) was to clone the repo, make the branch and commit changes to that branch.

If I'm reading that article (linked above) correctly, then next thing I need to do is push the branch so that I can move on to Step #2 (In the "Branch" menu, choose the branch that contains your commits.).

So I do a git push and I get:

D:\workspace\therepo>git push
warning: push.default is unset; its implicit value is changing in
Git 2.0 from 'matching' to 'simple'. To squelch this message
and maintain the current behavior after the default changes, use:

    git config --global push.default matching

To squelch this message and adopt the new behavior now, use:

    git config --global push.default simple

When push.default is set to 'matching', git will push local branches
to the remote branches that already exist with the same name.

In Git 2.0, Git will default to the more conservative 'simple'
behavior, which only pushes the current branch to the corresponding
remote branch that 'git pull' uses to update the current branch.

See 'git help config' and search for 'push.default' for further information.
(the 'simple' mode was introduced in Git 1.7.11. Use the similar mode
'current' instead of 'simple' if you sometimes use older versions of Git)

Username for 'https://github.com': myuser
Password for 'https://myuser@github.com':
remote: Permission to theuser/therepo.git denied to myuser.
fatal: unable to access 'https://github.com/theuser/therepo.git/': The
    requested URL returned error: 403

I can't tell what's going on here? Is the first warning/error (complaining about push.default) causing the second error (HTTP 403), or are they separate? Is my strategy (pushing the branch) wrong? I'm so confused.

smeeb
  • 27,777
  • 57
  • 250
  • 447

1 Answers1

13

Those instructions would work if you were a contributor to that project, but you're not. So you need to fork first. Read Fork a Repo. Clone your fork, make the branch there, push and then submit the pull request.

The your repository vs. their repository isn't really spelled out, but if you look start with your article and click the link for creating a branch you end up at Creating and deleting branches within your repository. Emphasis mine.

There's a bit more about the two different collaboration models (Fork & Pull vs. Shared Repository) in Using Pull Requests.

Steven Fisher
  • 44,462
  • 20
  • 138
  • 192
  • Thanks @Steven Fisher (+1) however I don't see that strategy listed on that GitHub article, am I looking at an old article? I guess I just have a tough time believing something that simple wouldn't be in GitHub's official tutorial for contributing to OSS... – smeeb Mar 14 '15 at 01:51
  • 1
    I don't know. Those instructions would work if you were part of the team authorized to do commits on that project. I've already sent them feedback asking them to fix that article. (Linking to your question here!) I'll add a link to a different article that might clear things up. – Steven Fisher Mar 14 '15 at 01:53
  • There, that link should help. – Steven Fisher Mar 14 '15 at 01:56
  • Thanks again @Steven Fisher (+1 again). I'm allmost there, sorry for the handholding, but if you can get me through this first pull request I should be good to go. So I followed your advice and was surprised to see that forking (which I have never done before either) created a new `myuser/therepo` under my repoositories on GitHub. I committed the changed branch, and see that the issue I am trying to close back on `theuser/therepo` now references my commit (to my own forked repo). Now I am extremely confused... – smeeb Mar 14 '15 at 01:58
  • Did I do this right? If so, what's the next step? Do they code review and accept/reject? When do I proceed to Step #2 in that article? Also, once they merge my commit/accept my request/whatever, I **don't** want `myuser/therepo` fork anymore...do I just delete this inside of GitHub? – smeeb Mar 14 '15 at 01:58
  • 1
    Proceed to step 2. As for deleting the fork, I wouldn't yet. If you want to contribute in the future you'll want to use it again. Honestly, I'm not sure what happens if you delete the fork before the pull request is accepted/rejected. It's probably fine, but… – Steven Fisher Mar 14 '15 at 02:02
  • Thanks again @Steven Fisher (+1) - however my branch (that I named `java8`) isn't showing up inside my forked repo or the original one (that I forked). – smeeb Mar 14 '15 at 02:05
  • You'll need to [set the upstream branch](http://stackoverflow.com/questions/6089294/why-do-i-need-to-do-set-upstream-all-the-time). – Steven Fisher May 25 '15 at 22:16