Skip to content

Instantly share code, notes, and snippets.

@raisedadead
Last active February 23, 2024 15:58
Show Gist options
  • Save raisedadead/069c6f121f49fbda256188e64b94de5f to your computer and use it in GitHub Desktop.
Save raisedadead/069c6f121f49fbda256188e64b94de5f to your computer and use it in GitHub Desktop.
Checkout, QA and Update PRs locally.
A workflow of working with pull-requests.
Following this you should be able to:
- review, QA, test PRs locally
- update PRs on freeCodeCamp's repository.
  1. Lets grab the changes first and have local ref branch

    git fetch upstream refs/pull/PULLREQ_NUMBER/head:pr-PULLREQ_NUMBER
  2. Checkout the PR

    git checkout pr-PULLREQ_NUMBER
  3. Make changes, like:

    git merge upstream/master

    Resolve commits.

    OR,

    Update files add your own commits, etc.

  4. Make a commit

  5. Finally push back to their branch to update the PR

    git push [email protected]:USERNAME/REPONAME.git pr-PULLREQ_NUMBER:THEIR_BRANCH_NAME

    We need this from the command line instructions. Be careful of the repo name because some maynot have the repo name same as us.

    Note it may require you to add --force to the push command in certain scenarios. BUT be EXTREMELY CAREFUL about that. Especially if you don't know what that may be doing on someone else's branch.

  6. Now you should be able to merge using Squash and merge on GitHub UI.

  7. Next you should clean your local like so:

    git checkout master
    git branch -D pr-PULLREQ_NUMBER

Happy Git Hacking and contributing!

Do NOT use this example on your Console / Terminal as it is! This is just for refrence to assist with the snippets in the above file.

~/DEV/freeCodeCamp master
❯ git fetch upstream refs/pull/20683/head:pr-20683
From github.com:freeCodeCamp/freeCodeCamp
 * [new ref]             refs/pull/20683/head -> pr-20683

~/DEV/freeCodeCamp master 31s
❯ git checkout pr-20683
Switched to branch 'pr-20683'

~/DEV/freeCodeCamp pr-20683
❯ git merge upstream/master

...

~/DEV/freeCodeCamp pr-20683
❯ git push [email protected]:dkempdesigns/freeCodeCamp.git pr-20683:patch-2
Enumerating objects: 444, done.
Counting objects: 100% (352/352), done.
Delta compression using up to 4 threads
Compressing objects: 100% (137/137), done.
Writing objects: 100% (254/254), 46.76 KiB | 3.60 MiB/s, done.
Total 254 (delta 171), reused 147 (delta 94)
remote: Resolving deltas: 100% (171/171), completed with 64 local objects.
To github.com:dkempdesigns/freeCodeCamp.git
   4c96bd8dc..6f4ce006b  pr-20683 -> patch-2
@cmccormack
Copy link

cmccormack commented Nov 2, 2018

Thank you for adding examples, very helpful!

The example shows git merge master - I assume you would only do this if your local master branch was just recently updated to the upstream/master correct? Would it be better to always use upstream/master?

@raisedadead
Copy link
Author

raisedadead commented Nov 3, 2018

@cmccormack yes you are correct. I updated the example. Thanks

@erictleung
Copy link

@raisedadead this might be useful as a starting point to make your scripts https://gist.github.com/piscisaureus/3342247

@raisedadead
Copy link
Author

Thanks @erictleung

@satdeveloping
Copy link

@raisedadead Please don't ever delete this Gist. I'm still using it today!

Bouncey

@raisedadead
Copy link
Author

Sure thing, Stuart! I'll keep it around.

Although I myself have transitioned to using the official gh cli for my needs.

Thanks.

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