<jupyter_start><jupyter_text>My First Pull Request TutorialLet's say you've caught a bug in open source code that you would like to correct. We'll walk through the steps to making a _pull request_ in this tutorial. What's a pull request? Some open source projects like [astropy](https://github.com/astropy/astropy) have >200 contributors located all around the world. How do you successfully manage the efforts of so many people? Contributors to the astropy repository _fork_, or make their own copy of, the astropy repository. They make changes on their fork, where no special permissions are needed to make changes. Then, they can offer those changes back to the _upstream_ repository, or the repository that they forked, in a _pull request_. The pull request is a means of offering your changes to the "official" version of the repository, where collaborators can review your changes and choose to _merge_ them, i.e. accept them into the upstream repository, or not. Exercise IntroWe will work on this [demo repository](https://github.com/bmorris3/bootcamp_demo/blob/master/functions.py), which has a bunch of non-functioning functions written in it. Your task in this lesson will be to:1. Fork the demo repo, and clone your fork2. Create an _issue_ where you describe what work needs to be done3. Create a _feature branch_4. Implement one of the non-implemented functions in your feature branch5. Add, commit and push your update to github6. Create a pull request to the upstream repository7. Pull changes from upstream 1) Fork, clone the demo repositoryFollow this link to the [demo repository](https://github.com/bmorris3/bootcamp_demo/), and click the **Fork** button in the upper-right corner of the webpage. This will create a copy of this repository that you have permission to edit as you please. When the repo has been successfully forked, you will be taken to a webpage that's labeled `/bootcamp_demo` in the upper-left corner. Now from your forked repo, click the green "Clone or download" button. You'll now see a link that you can use to _clone_ the repository. Copy that link, which looks like: `git@github.com:/bootcamp_demo.git`.In your Terminal, go to a directory where you want to put the demo repository, and run:<jupyter_code>%%bash
git clone <EMAIL>:bmorris3/bootcamp_demo.git<jupyter_output>Cloning into 'bootcamp_demo'...<jupyter_text>(where the `bmorris3` above is replaced with your username). Now change directories into the `bootcamp_demo` repo.In there, you will see a script called `functions.py`:<jupyter_code>%%bash
cd bootcamp_demo

cat functions.py<jupyter_output># Here are some functions that you can fill in to make them work.
# Replace the "raise NotImplementedError" line with the correct code!

def print_the_instructors_name():
    raise NotImplementedError

def print_the_number_of_this_room():
    raise NotImplementedError

def split_this_string_at_each_space(input_string):
    raise NotImplementedError

def take_the_average_of_these_numbers(a, b):
    raise NotImplementedError

def print_the_time_now_using_astropy():
    raise NotImplementedError

def return_the_minimum_of_two_numbers(a, b):
    raise NotImplementedError

def return_the_std_of_two_numbers(a, b):
    raise NotImplementedError<jupyter_text>There are a bunch of functions in this file that are not yet implemented. Their names tell you what they intend to do, but the source of each function simply says: "when this function is executed, raise an error".Chose one of these functions to work on, or chose to add a new function of your own. 2) Create an issueWhen you find a bug or chose to add a new feature to a repository, you should create an [_issue_ on the GitHub page of the upstream repository](https://github.com/bmorris3/bootcamp_demo/issues). Issues are useful because they allow you to solicit for help from the other contributors, and to start discussions about new features, bugfixes, improvements, etc. They also form a public record of previous discussions, which can be very useful for future contributors. Click [here](https://github.com/bmorris3/bootcamp_demo/issues/1) to see a demo issue that I created. Issues usually point to a particular piece of code and ask why or how it's supposed to work, or demonstrate an unexpected output from a function.Post an issue in the demo repo, volunteering to implement one function. You can tag people in the issue (like me, @bmorris3) if you want them to be notified to look at the issue. 3) Create a branchNow you are going to implement your new feature. Before you do so, you should create a _branch_. A branch is an independent copy of a repository that has its own history, independent of other branches. This is useful if you're developing multiple features at once – each feature should be developed on its own branch.To see what branches exist in this repository, type:<jupyter_code>%%bash
cd bootcamp_demo

git branch<jupyter_output>* master<jupyter_text>The branch that you're currently working on has a `*` next to its name. To create a new branch called `new-feature`, you can type:<jupyter_code>%%bash
cd bootcamp_demo

git branch new-feature<jupyter_output><empty_output><jupyter_text>but you should create a branch with a more descriptive name. Now if you check the branches:<jupyter_code>%%bash
cd bootcamp_demo

git branch<jupyter_output>* master
  new-feature<jupyter_text>You'll see the new branch exists. To work on the new branch, try:<jupyter_code>%%bash
cd bootcamp_demo

git checkout new-feature<jupyter_output>Switched to branch 'new-feature'<jupyter_text>You're now working on your new feature branch. You can check that by running `git status`, which will tell you that you're working `On branch new-feature`.To switch back to the master branch, you could `git checkout master`. 4) Implement a new featureNow make your change to the `functions.py` file. You can chose to edit one of the existing functions, create a new one, or add a comment somewhere. Be creative! 5) Pushing your change to your repo on GitHub Before you can offer this change to the upstream repository, you have to push your changes to GitHub. This is how we'll do that:1. `add` the file that has changes that you want to track2. `commit` the changes with a descriptive message3. `push` the changes to GitHub<jupyter_code>%%bash
cd bootcamp_demo

git add functions.py
git commit -m "Added a newline"
git push origin master<jupyter_output>[new-feature 15dbf2d] Added a newline
 1 file changed, 1 insertion(+)<jupyter_text>6) Creating a pull requestNow when you visit your repository on GitHub, you'll see that the `functions.py` file has the update that you made on your local machine. In order to offer that change to the upstream repo, click the `New Pull Request` button in the middle-left of the page. You should now see a `diff` of the file that you changed, showing the code that you removed (or changed) in red on the left, and the code that you added on the right in green. Click the green `Create Pull Request` button to go to the pull request page. At the top of the page, you should now see "Open a pull request". Give your PR a title that nicely summarizes what you did in a few words. Explain in more detail what you did in the "comments" section, and tag me (`@bmorris3`) asking for my comments. Click the last green button to submit the pull request. Brett will now be notified about the PR, and will review the code, and even merge it. 7) Pull changes from upstreamOnce you've made your pull requests, I will _merge_ some of them. After the merge, your commits will be applied to the _upstream_ repo. But now your master branch no longer reflects what the upstream repo looks like. To update your master branch, let's change branches to _master_:<jupyter_code>%%bash
cd bootcamp_demo

git checkout master<jupyter_output>Your branch is up-to-date with 'origin/master'.<jupyter_text>Now we need to setup a _remote_ for upstream. A remote is a GitHub address other than the one for your fork of the upstream repository. To see what remotes you currently have in this repo, do:<jupyter_code>%%bash
cd bootcamp_demo

git remote -v<jupyter_output>origin	<EMAIL>:bmorris3/bootcamp_demo.git (fetch)
origin	<EMAIL>:bmorris3/bootcamp_demo.git (push)<jupyter_text>(your origin will point towards the _fork_ that you made). Now we'll add a remote for upstream, which is my version of the repository:<jupyter_code>%%bash
cd bootcamp_demo

git remote add upstream <EMAIL>:bmorris3/bootcamp_demo.git
git remote -v<jupyter_output>origin	<EMAIL>:bmorris3/bootcamp_demo.git (fetch)
origin	git<EMAIL>:bmorris3/bootcamp_demo.git (push)
upstream	<EMAIL>:bmorris3/bootcamp_demo.git (fetch)
upstream	<EMAIL>:bmorris3/bootcamp_demo.git (push)<jupyter_text>Now you can _pull_ the changes that have been made on the upstream branch down to your fork:<jupyter_code>%%bash
cd bootcamp_demo

git pull upstream master<jupyter_output>Already up-to-date.
{'fraction_non_alphanumeric': 0.05758222022673701, 'fraction_numerical': 0.004602087776405882, 'mean_word_length': 5.0943912448700415, 'pattern_counts': {'":': 0, '<': 43, '<?xml version=': 0, '>': 44, 'https://': 5, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 1, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '11', 'dir': 'jupyter-structured-clean-dedup', 'id': '432955', 'license': 'BSD-3-Clause', 'n_tokens_mistral': 2518, 'n_tokens_neox': 2414, 'n_words': 1262, 'path': '2019-bern/11-Extras/intro_to_pr.ipynb', 'repo_name': 'bmorris3/past-astropy-workshops', 'size': '8962'}