Skip to main content

GitKit (2nd ed.): Learn git and GitHub in Context

Section 2.8 Cloning Your Origin

The next step in the basic FOSS workflow is to ensure that you have a clone of your origin repository in your development environment as shown in Figure 2.8.1. Having a clone of your origin in your development environment will allow you to edit the files to fix the issue that you have been assigned and add those changes to the repository.
Creating a clone of your origin repository creates a copy of it in your development environment. This copy is your local copy.
Figure 2.8.1. Cloning your origin repository from your GitHub space to your development environment.

Subsection 2.8.1 Clone URL

In order to clone a repository into your development environment you will need the clone URL for that repository. The steps in this section will help you find the clone URL for your origin repository.

Exercises

1.
Visit the GitHub page for your origin repository.
Hint.
You can find the URl of your origin (i.e. your fork of the GitKit FarmData2 upstream) in your answer to Exercise 2.6.3.
2.
Find and click the green "Code" button.
The green "Code" button in GitHub.
3.
Open the "Local" and "HTTPS" tabs as shown here:
The GitHub dialog showing the clone URL.
The URL in the "Clone using the web URL" box is the clone URL that you will need to clone your origin repository.
4.
Copy and paste the clone URL that you will use to clone your origin as your answer to this exercise.
Hint.
Be sure you are using your GitHub origin repository (see Exercise 2.6.3). This clone URL should contain your GitHub username and end in .git.

Subsection 2.8.2 git clone

The git clone command will make a copy of your fork on GitHub and make the Local Copy on your computer (in your development environment). Refer to Figure 2.8.1.
Now that you have the clone URL for your origin repository, use the steps in this section to clone your origin into your development environment.

Exercises

1.
The git clone <URL> command is used to clone your origin repository into your development environment.
Give a command that will clone your origin into your development environment.
3.
    Which of the following appear in the output from entering the command from Exercise 2.8.2.2?
  • Cloning into
  • Sending objects
  • Deleting objects
  • Resolving deltas
  • Counting objects
  • local:
Hint.
Look at the output in your terminal.
4.
    Which line of output from entering the command from Exercise 2.8.2.2 indicates the directory into which the repository was cloned?
  • Cloning into
  • remote: Enumerating objects
  • remote: Counting objects
  • remote: Total
  • Receiving objects
  • Resolving deltas
Hint.
Look for a line in the output that begins with "Cloning into".

Subsection 2.8.3 Exploring Your Cloned Repository In Your Development Environment

In this section you will briefly explore the GitKit FarmData2 repository that you have cloned into your development environment.

Exercises

1.
Use the cd command in the Terminal to change into the directory containing your clone of the GitKit FarmData2 repository.
See Exercise 2.8.2.4 for the name of the directory.
2.
    Use the ls -a command to display the names of all of the files and directories in your clone of the GitKit FarmData2 repository.
    Compare these files and directories to those in your origin repository on GitHub.
    Check all files and directories that do not appear both locally and on GitHub.
  • .
  • ..
  • .git
  • README.md
  • .kit
  • .vscode

Subsection 2.8.4 git remote

In this section you will see that your clone keeps track of the location of your origin repository. It does this using a piece of information called a remote, which Git uses to store the URLs of remote repositories in the cloud (e.g. on GitHub).
The command git remote on its own will show you the names of the remotes that git knows about, but not their URLS.
If you want to have git display the URLs of the remotes as well, you will need to add the -v or --verbose flag: git remote -v

Exercises

1.
    Which command will show you the URL(s) of the remote(s) that git knows about?
  • git remote -v
  • git remote
  • git remote -url
  • git url
Hint.
You are asking git remote to give you more information.
2.
    Execute the command git remote -v in your terminal. How can you tell from that output that your clone knows about your origin?
  • The "origin" lines have a URL with your GitHub username in them.
  • There are lines that say "origin".
  • The "origin" lines have a URL that points to GitHub.
  • It is not possible to tell from the output.
Hint.
Look closely at the "origin" URLs.
3.
    How is the origin remote that you see in the output of the Exercise 2.8.4.2 command represented in Figure 2.8.1?
  • The orange dotted arrow from the clone to the origin repository.
  • The orange dotted arrow from the origin to the upstream repository.
  • The orange dotted arrow from the clone to the upstream repository.
  • The blue "Clone" arrow from the origin to the cloned repository.
  • The origin remote is not represented in the figure.
Hint.
Which arrow would represent the clone knowing the location of the origin?
4.
    Which step of the basic FOSS workflow requires that your clone know the location of your origin repository?
  • Pull request
  • Fork
  • Clone
  • Edit
  • Push
Hint.
Think about which step of the basic FOSS workflow will need to send information from the clone back to the origin.

Subsection 2.8.5 Opening the GitKit FarmData2 Repository Folder

You cloned your fork of the GitKit FarmData2 upstream repository into a folder in your development environment with the command in Exercise 2.8.2.2.
But, you need to reopen your development environment in that folder to take advantage of all of the features that the KitClient provides for you.

Exercises

1.
Open your clone of the GitKit FarmData2 repository.
You can do this by going to the "hamburger" (≡) menu in the upper left of your development environment window.
Choose File > Open Folder...
Select the folder containing your clone of the GitKit FarmData2 repository and click OK.
You will see Setting up your Codespace, and then your terminal will show a message from the Kit-tty.
2.
    The output in Exercise 2.8.5.1 should contain a message from the Kit-tty. What is the Kit-tty?
  • Your personal virtual assistant.
  • A terminal.
  • A teletypewriter.
  • A pet kitten.
Hint.
The "Kit-tty" introduces itself using the line "😺💻 Meow, Kit-tty here!" Read the description of the "Kit-tty" that follows this line.
Be sure to keep your eyes open for messages from the Kit-tty as you work on the GitKit exercises. The Kit-tty will help you to stay on track and may save you a lot of time by preventing you from going down an incorrect path.
You have attempted 1 of 11 activities on this page.