Skip to content

Instantly share code, notes, and snippets.

@toonn
Created December 31, 2017 01:07
Show Gist options
  • Save toonn/27e326b23b0f7967686e00caf4f0319d to your computer and use it in GitHub Desktop.
Save toonn/27e326b23b0f7967686e00caf4f0319d to your computer and use it in GitHub Desktop.

So you've cloned a repo and made some changes? Now you want to submit a PR. This'll make it look like you didn't forget to fork before making the changes. Zero loss of face and endless enjoyment.

  1. Fork the repo on GitHub.

  2. Rename the local remote.

    git remote rename origin upstream

  3. Add your fork as the new origin.

    git remote add origin git@github:...my-fork.git

  4. Fetch the fork to update your branches.

    git fetch origin

  5. Create a new branch with your changes.

    git branch changes

  6. Checkout your fork's master branch. (This resets the current master branch so changes will be lost.)

    git checkout -B master --track origin/master

  7. Rebase your changes onto the new master.

    git rebase changes

  8. Optionally remove your temporary changes branch.

    git branch -d changes

  9. Push your changes to your fork so you can create a PR on GitHub.

    git push

Credit goes to @jagregory for the original this is based on.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment