Git Product home page Git Product logo

github-pull-request-basics-v-000's Introduction

Github Pull Request Basics

Objectives:

  1. Understand what a pull request is
  2. Identify how to create a pull request from one fork to another
  3. Identify how to add commits to an existing pull request

Overview:

The concept of a pull request is unique to Github. It is a request for the owner of a receiving repository to take your changes, that you made on your own copy of the repo ("your fork"), and "pull" them into the owner's repository. Pull requests power the open source community. Through this process, anyone can fork a repo, make changes and submit a pull request. Instead of the owner working on their codebase alone, anyone can contribute: tests, documentation fixes, new features, awesome layout and graphics, etc...

There are some vocabulary words that we need to keep in mind in order to make sure that we're all on the same page.

  • revision control system: a software program that keeps tracks of updates / deletions / additions / changes to a collection of content (usually a directory)
  • "repository" (or "repo"): a directory of content (including subdirectories) which is managed by git (or, "under revision control")
  • "organization" (or "org"): a parent entity which "owns" a repo. This might be an organization (IBM, Microsoft, the Python foundation) or it might be an owning human (sgharms). In the case of Learn.co labs, "orgs" are learn-co-curriculum and learn-co-students
  • "fork:" to make a copy of the repository owned by one org and add it within another org. sgharms might "fork" ruby/ruby (that is ruby org's ruby repo) to his own org.
  • "clone:" to copy a remote repo (on Github, typically, but this could be from a remote server, from a USB drive, even from another directory on your local system) to a local directory with the same name that's under git revision control
  • "pull request:" to request that the owner of another org take changes you made to your copy of the repo and integrate it into theirs as if you had done the work on theirs directly. Here is a great example of a pull request on the Ruby codebase.

Let's go over a conceptual example. It's OK if this feels a bit confusing at first, you'll work through this countless times and eventually your brain and fingers will both grasp what's going on.

Pull Request to a Source Repository

  1. Suppose you "fork" a repo from https://github.com/learn-co-students/awesome-lab.
  2. You now have a copy of that repo on your Github account ("organization") i.e. https://github.com/your-user-name/awesome-lab. Technologists would say you "forked" the awesome-lab repo from the learn-co-students organization to the your-user-name organization.
  3. But you still don't have a local copy of this repository on your computer. To do so you will...
  4. Clone from your fork to your computer. There's no reason you couldn't clone from the original repo. However, most repo owners don't want random people on the Internet (that's you!) committing to their repo. What you're going to do is establish a "parallel" repo in your org and then tell the "source" repo "Hey, I added something awesome, I'm requesting that you pull it in."
  5. Make some changes on your local machine
  6. Push your code from your local system back to your fork
  7. Create a pull request that requests your improved code be "pulled" into the source repo.

Pull Request From One Fork To Another

Here's a story:

  1. You fork the repository https://github.com/learn-co-students/awesome-lab to https://github.com/your-user-name/awesome-lab.
  2. You make some changes to your newly forked repo.
  3. Another student forks the repository https://github.com/learn-co-students/awesome-lab as https://github.com/their-user-name/awesome-lab.
  4. You make some changes and you want to send a pull request to their fork https://github.com/their-user-name/awesome-lab. How do you do this?

Amazingly, git doesn't care whether one repository is the "source" or is "another fork of the source." Amazingly, if GitHub were to be wiped off the earth tomorrow, local copies on hundreds of laptops 'round the world are just as good as the copy that GitHub had! This is why git is called a "Distributed Version Control System." So, to share a pull request with another student follows the same process as forking some famous project (like Ruby or jQuery).

Step 1

Click on the New Pull Request button.

Step 2

Here you can choose the base fork, which will be their-user-name/awesome-lab. Then choose the head fork, which will be your-user-name/awesome-lab

Now click Create pull request.

Add Commits To An Existing Pull Request

Let's say you make a pull request from https://github.com/your-user-name/awesome-lab to https://github.com/learn-co-students/awesome-lab. Then you notice you made a typo in your code. All you have to do is fix the typo, commit it and push up the changes to your branch. As long as the pull request already exists, the commits will be added automatically.

View Github Pull Request Basics on Learn.co and start learning to code for free.

test

github-pull-request-basics-v-000's People

Contributors

daleterrell avatar maxwellbenton avatar sgharms avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.