Forking A Repository

VIDEO

In version control terminology if you "fork" a repository that means you duplicate _it. Typically you fork a repository that belongs to someone else. So you make an identical copy of _their _repository and that duplicate copy now belongs to _you.

This concept of "forking" is also different from "cloning". When you clone a repository, you get an identical copy of the repository. But cloning happens on your_local_machine and you clone a_remote_repository. When you fork a repository, a new duplicate copy of the_remote_repository is created. This new copy is_also a remote_repository, but it now belongs to you.

AforkSubcommand?

Forking is not done on the command line; there is nogit forkcommand. Go ahead, try running the following command:

$ git fork

Running the (nonexistent!)git forkcommand on the terminal. Git doesn't have aforksubcommand, so it responds with a suggestion to use an alternative command.

As you can see, trying to run thegit forkcommand produces an error. (Also,fsckis not a rude word, it means "filesystem check" and refers to auditing the files for consistency.)

Alter a Cloned Repo

Do the following steps and answer the question below.

Task List

  • usegit cloneto cloneLam's my-travel-plans project

  • make at least one change to it

  • commit the change(s)

  • usegit pushto push your change back to Lam's project

QUESTION 1 OF 2

Were you able to successfully push your changes to the remote repository?

  • Yes

  • No

SUBMIT

QUESTION 2 OF 2

One of the lines that was displayed after you tried to push includes the word "fatal". What comes right after that word?

  • you don't have the correct permissions

  • unable to access

  • are you the owner

  • try using a different account

SUBMIT

We can see from this little experiment that if a repository doesn't belong to your account then it means you do not have permission to modify it.

This is where forking comes in! Instead of modifying the original repository directly, if you fork the repository to your own account then you will have full control over that repository.

Forking Lam's Project

I'm going to clone Lam's project myself. My account does not have permission to edit her repository directly, so I'll fork the repository to my own account.

I want you to sign into your GitHub account and follow along with the rest of these steps:

Task List

  • Go toLam's my-travel-plans projectin your browser

  • Click the fork button to copy over her repository to your account

  • Verify that you now have Lam's project listed in your Repositories

Let's take a look at the name of the repository:

Forking a project displays the new project name next to your GitHub profile name. Also, below that it says where the original project exists.

See how this shows my account name (richardkalehoff) and the name of the repository? But then just beneath that it says "forked from udacity/course-collaboration-travel-plans". This shows that this project is in _my_ account but that it has a connection to the original project that it was copied from.

That's pretty neat, right?!? You can fork any public repository that's up on GitHub right now - which means you can get a copy of that repository in your own account that you will have total control over.

Why don't you go fork a few repositories just to get some practice! Here a few you can try it out on:

Push/Pull To The Fork

Because forking a repository gives you a copy of it in your account, you can clone at down to your computer, make changes to it, and then push those changes back to the forked repository. But you need to keep in mind that it'll be pushing the changes back to_your_remote repository not to the_original_remote repository that you forked from.

VIDeO

Recap

Forking is an action that's done on a hosting service, like GitHub. Forking a repository creates an identical copy of the original repository and moves this copy to your account. You have total control over this forked repository. Modifying your forked repository does not alter the original repository in any way.

results matching ""

    No results matching ""