1 of 6

Git pull requests

Michael Gray

Bristol CodeHub JS101

2 of 6

Fork and clone

HowTo: https://help.github.com/articles/fork-a-repo/

Our repo: https://github.com/CodeHubOrg/organisations-database

  • Fork it on GitHub
  • Clone it to my machine
    • In browser, go back to CodeHubOrg repo to get URL
    • git remote add upstream https://…

3 of 6

Connect upstream

To make the connection back to the CodeHubOrg repo:

  • In local repository:

4 of 6

Branch and edit

  • make a branch for your edits
    • git checkout -b whizzy-feature
  • do your edits
  • commit (maybe more than one)
    • git commit -m ‘Added useful stuff’ -- file1 file2
  • push the branch to your GitHub repo (master)
    • git push origin whizzy-feature
  • Back on GitHub, create a pull request
    • it’ll prompt you to!

5 of 6

Keep everything up-to-date

  • Once your pull request has been merged:
    • git checkout master
    • git pull -n upstream # and check…
    • git pull upstream # before doing it!
    • git pull upstream master === (git fetch upstream; git merge upstream/master)
  • You are now up-to-date with CodeHub locally…
  • ...but not on GitHub, so:
    • git push origin master

All good!

And repeat...

6 of 6

It’s a circle...

  • pull changes
    • from upstream (github/CodeHubOrg/…)
    • to your local repo.
  • branch and develop a change set.
  • push your branch
    • from your local repo
    • to origin (github/yourAccount/…)
  • submit pull request on GitHub.
  • maintainer accepts (hopefully) your pull request
    • which merges the changes into github/CodeHubOrg/… (upstream)
  • and repeat!