<commit_before># Collaborative Fan Fiction


### The Challenge
Make a pull request to add to this collaborative tale about Harry and his friends.

You will:

* Edit the files in this project
* Add those changes to your staging area
* Commit them
* And push them to github
* You'll then (if you're really brave) learn how to manage merge conflicts!

####  **Here's how ...**

1. ###### Open your terminal and navigate to where you're going to store these files on your computer.
  *(just shout out if you don't know who or what your terminal is!)*


2. ###### Clone this repository


  ```sh
  $ git clone https://github.com/railsgirlswgtn/fan-fiction-github-challenge.git
  ```

  This creates a copy of this **repository** on your computer. In other words, it creates a new folder called `fan-fiction-github-challenge` full of everything you see here.


3. ###### Navigate into the folder

  ```sh
  $ cd fan-fiction-github-challenge
  ```

  `cd` is short for **change directory**. This is how you navigate through your file system using the terminal.

  You can go back to the directory you were in before by typing `cd -` or the directory that contains the one you are in by typing `cd ..`.

  If you want to see what directory you're in, you can type `pwd`, which is short for **print working directory**. To see what is in the directory you're in, type `ls`, which is sort of a weird abbreviation for **list** I guess.


4. ###### Checkout a branch


  ```sh
  $ git checkout -b your_name
  ```

  This creates a new **branch**. That means it keeps track of changes separately.

  You don't need to surround the name of your branch with brackets or anything like that, but generally it should just be made up of letters, numbers, `-`s and `_`s. So you could write `git checkout -b terrible_dragons` or `git checkout -b revenge-of-albus-severus`.

  You need the `-b` to create the new branch. Without `-b` it will want to change to a branch that already exists with that name. That can be useful later.


5. ###### Make an edit


  Open the file fan-fiction.md in your text editor. This file is in **markdown**. Check out [this guide](https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet) to formatting in markdown. You can embed images, links, lists, headings, whatever you like!


6. ###### Add your changed file to the staging area


  ```sh
  $ git add fan-fiction.md
  ```

  This puts fan-fiction.md into the **staging area**. If you make another change, it will be removed from it.  

  To see what files you've changed and what is in your **staging area**, you can type `git status`. `git diff` will show you a more detailed view of the changes in your files.


7. ###### Commit your changes with a sweet commit message


  ```sh
  $ git commit -m 'Hermione turns down an office at the Department of Magical Law Enforcement'
  ```

  A commit is the point at which the state of everything in the **staging area** is recorded.

8. ###### Push your changes to a branch on github


  ```sh
  $ git push origin your_branch_name
  ```

  This copies your branch information to the repository on GitHub.

  You should be able to see your branch [here](https://github.com/railsgirlswgtn/fan-fiction-github-challenge/branches).


9. ###### Create a pull request to master on github


  ![](http://i.imgur.com/zZPQLw0.png)

  Go through the steps to create a pull request on GitHub. Genevieve, Rob, and Merrin will merge pull requests into master.

#### Updating your repository
  Hopefully this repository will be full of delightful contributions to literature. That means that you will have to **pull** from **origin** to get everyone elses' commits.

  1. First of all, if you are on a branch, make sure you have **committed** all of the changes you want to make. When you type `git status`, you want it to say: 'nothing to commit, working directory clean'.
    * There are more detailed instructions above about `git add` and `git commit`.
    * If you don't want to commit but you do want to switch branches, you can use `git stash` to hide the changes you have made and `git stash pop` to bring them back.

  2. Next, check out the master branch: `git checkout master`.

  3. Your task now is to `git pull`.
    * As long as your working directory is clean and you have only made commits to your branch and not to master, this should just pull the changes down from GitHub that everyone else has made. Your master branch should now look like the master branch on GitHub.
    * If you have made commits to master, you might get merge conflicts here. Skip ahead to point 8 for tips on resolving merge conflicts, and find a coach to get some help with getting your commits onto a branch.

  4. Now head back to the branch that your commits are on: `git checkout whatever_your_branch_is_called`.

  5. The next part is hard. Are you ready for it?

  6. Are you sure?

  7. Ok. Take a deep breath and type `git merge master`.
    * If you haven't made any commits since making this branch, or if you have only edited things that don't conflict with anything else, this will probably just come up with a text editor screen asking you for a commit message. You can just exit out of it by typing `:q`. Shazam. You are done. Proceed to step 11.
    * If you have made commits since making the branch, given that there a bunch of people editing the same file, it is extremely likely that you will have **merge conflicts**. You'll see this:

      ```<commit_msg>pull instructions<commit_after># Collaborative Fan Fiction


### The Challenge
Make a pull request to add to this collaborative tale about Harry and his friends.

You will:

* Edit the files in this project
* Add those changes to your staging area
* Commit them
* And push them to github
* You'll then (if you're really brave) learn how to manage merge conflicts!

####  **Here's how ...**

1. ###### Open your terminal and navigate to where you're going to store these files on your computer.
  *(just shout out if you don't know who or what your terminal is!)*


2. ###### Clone this repository


  ```sh
  $ git clone https://github.com/railsgirlswgtn/fan-fiction-github-challenge.git
  ```

  This creates a copy of this **repository** on your computer. In other words, it creates a new folder called `fan-fiction-github-challenge` full of everything you see here.


3. ###### Navigate into the folder

  ```sh
  $ cd fan-fiction-github-challenge
  ```

  `cd` is short for **change directory**. This is how you navigate through your file system using the terminal.

  You can go back to the directory you were in before by typing `cd -` or the directory that contains the one you are in by typing `cd ..`.

  If you want to see what directory you're in, you can type `pwd`, which is short for **print working directory**. To see what is in the directory you're in, type `ls`, which is sort of a weird abbreviation for **list** I guess.


4. ###### Checkout a branch


  ```sh
  $ git checkout -b your_name
  ```

  This creates a new **branch**. That means it keeps track of changes separately.

  You don't need to surround the name of your branch with brackets or anything like that, but generally it should just be made up of letters, numbers, `-`s and `_`s. So you could write `git checkout -b terrible_dragons` or `git checkout -b revenge-of-albus-severus`.

  You need the `-b` to create the new branch. Without `-b` it will want to change to a branch that already exists with that name. That can be useful later.


5. ###### Make an edit


  Open the file fan-fiction.md in your text editor. This file is in **markdown**. Check out [this guide](https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet) to formatting in markdown. You can embed images, links, lists, headings, whatever you like!


6. ###### Add your changed file to the staging area


  ```sh
  $ git add fan-fiction.md
  ```

  This puts fan-fiction.md into the **staging area**. If you make another change, it will be removed from it.  

  To see what files you've changed and what is in your **staging area**, you can type `git status`. `git diff` will show you a more detailed view of the changes in your files.


7. ###### Commit your changes with a sweet commit message


  ```sh
  $ git commit -m 'Hermione turns down an office at the Department of Magical Law Enforcement'
  ```

  A commit is the point at which the state of everything in the **staging area** is recorded.

8. ###### Push your changes to a branch on github


  ```sh
  $ git push origin your_branch_name
  ```

  This copies your branch information to the repository on GitHub.

  You should be able to see your branch [here](https://github.com/railsgirlswgtn/fan-fiction-github-challenge/branches).


9. ###### Create a pull request to master on github


  ![](http://i.imgur.com/zZPQLw0.png)

  Go through the steps to create a pull request on GitHub. Genevieve, Rob, and Merrin will merge pull requests into master.

#### The next step: Updating your repository

  Hopefully when you create your pull request it should be able to successfully be merged and you should see this button:
  ![]()

  If you don't, you haven't done anything wrong, your branch is most likely just slightly out of date - maybe someone else's pull request was merged to master in the time since you cloned the repo.
  That means that you will have to **pull** from **origin** to get everyone elses' commits into your own.
  If you've got your Gryffindor or Ravenclaw hat on, you can do this yourself. Ready?

  1. First of all, if you are on a branch, make sure you have **committed** all of the changes you want to make. When you type `git status`, you want it to say: 'nothing to commit, working directory clean'.
    * There are more detailed instructions above about `git add` and `git commit`.
    * If you don't want to commit but you do want to switch branches, you can use `git stash` to hide the changes you have made and `git stash pop` to bring them back.

  2. Next, check out the master branch: `git checkout master`.

  3. Your task now is to `git pull`.
    * As long as your working directory is clean and you have only made commits to your branch and not to master, this should just pull the changes down from GitHub that everyone else has made. Your master branch should now look like the master branch on GitHub.
    * If you have made commits to master, you might get merge conflicts here. Skip ahead to point 8 for tips on resolving merge conflicts, and find a coach to get some help with getting your commits onto a branch.

  4. Now head back to the branch that your commits are on: `git checkout whatever_your_branch_is_called`.

  5. The next part is hard. Are you ready for it?

  6. Are you sure?

  7. Ok. Take a deep breath and type `git merge master`.
    * If you haven't made any commits since making this branch, or if you have only edited things that don't conflict with anything else, this will probably just come up with a text editor screen asking you for a commit message. You can just exit out of it by typing `:q`. Shazam. You are done. Proceed to step 11.
    * If you have made commits since making the branch, given that there a bunch of people editing the same file, it is extremely likely that you will have **merge conflicts**. You'll see this:

      ```
{'fraction_non_alphanumeric': 0.07890783776619245, 'fraction_numerical': 0.0035345056110276576, 'mean_word_length': 3.538091419406576, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 6, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1606846', 'n_tokens_mistral': 3157, 'n_tokens_neox': 2921, 'n_words': 1797}