2

I forked a repository on Github, added some changes to a file, ran lint and tests, committed to my repo, initiated a pull request, conversed w/ original author, pull request accepted and combined into original repo. So far, so good.

Now, I've added changes to another file, committed (linted, tested etc.), and went to Github to initiate a new pull request, but the list of past pull requests on the repo shows 0, and when I click the "New pull request" button, it creates a pull request containing both files.

Clearly, I've missed a step between 1 and 2. Could someone clue me in to what am I missing? Do I have to re-fork the original repo?

Traveling Tech Guy
  • 27,194
  • 23
  • 111
  • 159

1 Answers1

1

First, always make your pull request in a branch.

Second, when you add some change (in a branch), update your master branch from the original repo:

git remote add original /url/to/upstream/repo
git fetch original
git checkout master
# make sure you don't have any work in progress
git reset --hard original/master

Then rebase your current fix branch on top of master:

git checkout fixbranch
git rebase master

You can then push that new branch to your origin (your fork):

fork

See more with this couple of tips on pull requests.

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Thanks for the detailed reply! So, should I attempt this on the already forked repo, or should I just get rid of it, fork again, and follow your suggestions from scratch? – Traveling Tech Guy Oct 10 '13 at 19:26
  • @TravelingTechGuy in theory, you don't have to fork again, but depending on what you already pushed, that might be the simplest solution. – VonC Oct 10 '13 at 19:29
  • Following your directions, getting: `git reset --hard original/master fatal: ambiguous argument 'original/master': unknown revision or path not in the working tree. Use '--' to separate paths from revisions, like this: 'git [...] -- [...]'` – Traveling Tech Guy Oct 10 '13 at 19:56
  • @TravelingTechGuy I forgot the fetch step: `git fetch original`. I have edited the answer. – VonC Oct 10 '13 at 19:57