In this lab, we will be simulating the experience of contributing to an open source project on GitHub using the Forking Workflow. Recall from the previous lab that Branching requires "read-write" access a central, server-side repository on GitHub. Forking is a method of collaboration that allows anyone to contribute to an open source project without read-write permissions to a GitHub repository.
A "Fork" is a copy of a server-side Git repository (i.e. on GitHub) on another user's account. This allows the original repository owner to maintain their project without granting repository permissions to anyone else, while also giving users a copy of a project that they can manage on GitHub on their own. The benefit to open source communities is that data can be pushed and pulled between Forks through Pull Requests.
By the end of this lab, you will have experience with the following:
- Forking a repository from GitHub
- Cloning a forked repository to your computer
- Making commits to your forked repository
- Creating pull requests from your forked repository
- Linking specific Github Issues to pull requests
This particular simulation is for contributing to a recipe website. Your task will be to contribute a recipe to the website so that the entire class can have new recipe to experiment with in their own kitchen! While I am exciting to read the recipe you will be contributing, you will not be graded on the quality or sophistication of the recipe!
By completing this lab, you will have a copy of all of the code and files required for a Jekyll website using the Chowdown theme. You do not need to have Jekyll installed on your machine to complete this lab. You just need the ability to add files to the repository, edit them in VS Code (or your preferred plain text editor), and push commits
to GitHub.
- Have a recipe in mind, specifically a title, list of ingredients, and steps to make it. It can be anything you want.
- Have an image of the finished dish. You can contribute your own photo, or search Creative Commons for a generic photo of the dish that is licensed for re-use.
-
Fork this repository to your GitHub account: Click on the
Fork
button near the top-right of this page. This will create a copy of the repository to your GitHub account. At the end of the process, you should be at the GitHub version of your forked repository. The URL will look something like this:https://github.com/USERNAME/forking
-
Clone this repository to your computer [help guide], something like:
git clone [email protected]:chrisdaaz/forking.git
-
Open the repository in your text editor (e.g. VS Code)
To complete this assignment, you only need to add two files. The first file will be a recipe file within the _recipes
subfolder; the second file will be an image file (.png | .jpg | .gif
) added to the images
subfilder. Here's how:
- Create a new markdown file within the
_recipes
directory named after your dish. Use Kebab case for the file name. and.md
as the file extension. For example, a recipe for Banana Bread would bebanana-bread.md
. It's very important that this file is save to the_recipes
directory.
Recipes are written in Markdown and contain a few special sections:
- The frontmatter, which contains:
- Title, Image, and Layout (which is "recipe")
- Ingredients (a list of things in the dish)
- Directions (a list of steps for the dish)
- Body content (for intros, stories, written detail, credits)
You can an example on the Red Berry Tart recipe.
Or you can see the example in the _recipes/bagels.md
file (you can copy the contents of the file to your new file and swap out the content with your recipe information).
- Save the file when you're finished writing the recipe.
For this part, you can use your default file explorer to copy your image to the repository. On your computer, the repository will be in a folder called recipe-lab
.
- Save the image file (
.jpg
,.png
, or.gif
) to the/images
folder of the repository. Make sure that the image file name and extension matches the value for theimage
filed in your corresponding markdown file. For example, if you're adding an image file calledbagels.jpg
to the/images
folder, thebagels.md
markdown file for the recipe should also include the lineimage: bagels.jpg
near the top of the file.
-
Open your terminal in VS Code (
File menu > Terminal > New Terminal
) or terminal program (e.g. Git Bash). -
Run
git status
to make sure that Git is aware that you've created two new untracked files: a markdown file (.md
) and an image file. -
Commit the files to your repository:
git commit -am "adds a new recipe"
Note: you are not making a new branch for this commit. You are committing directly to the main
branch of your Fork
of the recipe-lab
repository.
-
Push the
commit
to yourFork
on GitHub:git push
-
Now, when you visit your
Fork
on Github, you will notice that your repository is one commit ahead ofhttps://github.com/chrisdaaz/recipe-lab
. GitHub will be aware of this and will ask you if you'd like toCompare and Pull Request
. -
Create a Pull Request from your forked version of
recipe-lab
to my original version ofrecipe-lab
on GitHub [help guide].
Contributions to projects through pull requests are usually linked to Issues in the target repository. GitHub provides ticketing system (called "Issues") in every repository. This helps repository contributors keep track of work that needs to get done on the repository. Please reference Issue #1 in the Description of your Pull Request.
- In the
Title
field of the Pull Request, enter the name of your recipe. In theDescription
of your recipe, reference the GitHub Issue number in order to link your contribution to the requested work in the Issue tracker [here's a help guide on linking pull requests to issues].
TITLE: Buffalo Chicken Recipe
DESCRIPTION: references #1
- When you're ready, click on
Create Pull Request
. This will notify me that your work is complete. If the recipe looks good, I'll add it to the book and you will see it available here:
You're done!