8.2: GitHub Fork and Clone
Last updated
Last updated
At the end of this lesson, you should:
Be able to use the GitHub Fork feature.
Be able to use the git clone
command.
Be able to use the git push
command.
We will learn more features of Git and GitHub to start and submit SWE Fundamentals projects. As a reminder, Git is the version control system and GitHub is the code-hosting website built on top of Git. GitHub extends the capabilities of Git by adding visual code browsing, social features, and collaboration features.
In the below video we demonstrate git push origin master
, but for SWE Fundamentals git push
will suffice. origin
refers to the target Git remote, and master
refers to the target branch. Rocket Academy has updated our repos to use main
as the default branch name as per GitHub's latest convention, so if you wanted to specify the full command including remote and branch for SWE Fundamentals, you could use git push origin main
.
"Fork" is the GitHub term for copying a repo from one GitHub account to another. We can fork a repo by clicking the Fork button on a given GitHub repo page. Forking allows us to make changes to a repo and save those changes to our own GitHub account's copy of the repo. Our account's repo is essentially independent from the original, forked repo.
"Fork" is a GitHub concept. Forking is not built-in to the Git version control system.
We'll use a Git command to download or "clone" a copy of SWE Fundamentals starter code. <REPO_DOWNLOAD_URL>
is the download URL of our repo, obtained by clicking the Download Code button on the repo's GitHub page. <LOCAL_REPO_FOLDER_NAME>
is the name of the destination folder that is created (containing the contents of the repo) when we run the Git command.
Command Template
Sample Command
GitHub enables us to coordinate differences between local and "official" versions of the code, but we won't concern ourselves with that just yet.
We will learn 1 new Git command push
to send local code commits from our computers to GitHub. push
can also be used as a general command to move code between "remote" repos, but during SWE Fundamentals we will only be using push
to push code to GitHub.
Here is the workflow for SWE Fundamentals projects:
Go to the project repo page. Click the "Fork" button to copy the repo to our own GitHub account.
In the command line on our local computer, clone the repo from our own Github account's copy of the repo.
Once the repo is on our computer, make the changes we want, and follow the Git workflow and cheatsheet to commit those changes.
git push
our changes to our repo. Refresh the repo page to see our commits in the repo.
Create a pull request in GitHub. This connects our work on the repo in our account to the original Rocket Academy repo. Fill in the survey and submit.
Fork a copy of the Fundamentals Beat That! repo as setup for Project 2.
Clone the repo into a folder on your local machine.
Once you start working on your project, make frequent commits and use git push
to update your GitHub repo.