Skip to content

Latest commit

 

History

History
73 lines (45 loc) · 2.33 KB

forking.md

File metadata and controls

73 lines (45 loc) · 2.33 KB

Forking

A fork is a copy of a repository. Forking a repository allows you to freely experiment with changes without affecting the original project.

Most commonly, forks are used to either propose changes to someone else's project or to use someone else's project as a starting point for your own idea.

For a repository

Forking a repository is simple.

  1. On the top right corner of this project page, click Fork.
  2. That's it! You now have a copy of this project on your own profile.

forking

Clone your fork to your machine

  1. On GitHub, navigate to your fork of this project.
  2. Under the repository name, click Clone or download.

cloning

  1. In the clone with HTTPs section, click the icon to copy the URL for the repository.

copy url

  1. Open Terminal.
  2. Type git clone, and then paste the URL you copied. It will look like this, with your GitHub username instead of YOUR-USERNAME.
git clone https://github.com/YOUR-USERNAME/git-workshop
  1. Press Enter. Your local clone will be created.

Syncing a fork

It's good practice to regularly sync your fork with the original (upstream) repository.

Track the original project

  1. In your terminal, change directory into the project.
$ cd /Users/Enda/code/github.com/git-workshop
  1. Type git remote -v and press Enter. You will see the currently configured remote project on GitHub.
$ git remote -v
origin  [email protected]:YOUR_USERNAME/git-workshop.git (fetch)
origin  [email protected]:YOUR_USERNAME/git-workshop.git (push)
  1. We need to add the original project, known as the upstream, to our remotes.
$ git remote add upstream https://github.com/craicoverflow/git-workshop.git

Update your fork from upstream

  1. Fetch the latest branches and commits. Commits to master will be stored in a local branch, called upstream/master.

  2. Checkout your local master branch.

$ git checkout master
> Switched to branch 'master'
  1. Merge the changes from upstream/master into your local master branch. This brings your fork's master branch into sync with the upstream repository.