Menu

Log in

Sign up

From beginner to master of web design, coding, infrastructure operation, business development and marketing

  • COURSES
  • HTML & CSS Introduction
  • HTML & CSS Coding with AI
  • Linux Introduction
  • Docker Basics
  • Git & GitHub Introduction
  • JavaScript Coding with AI
  • Django Introduction
  • AWS Basics
  • Figma Introduction
  • SEO Tutorial for Beginners
  • SEO with AI
  • OTHERS
  • About
  • Terms of Service
  • Privacy Policy

© 2024 D-Libro. All Rights Reserved

Git & GitHub IntroductionChapter 3. Git & GitHub Project Setup

Project Member – Create Copy of Project Code on Local Computer (git clone)

Project Member – Create Copy of Project Code on Local Computer (git clone)

Creating a Local Copy of a Project with git clone

The git clone command is used to create a local copy of a Remote Repository – establish a link with a Remote Repository and bring the project directory from the Remote Repository with commit histories to your local computer.

This command is used only the first time you bring the project directory to your local computer. The git clone command establishes a connection between the Rremote Repository and your local computer by registering the URL to define the location of the Remote Repository on your computer. Once the connection is established, you can Pull or Fetch the Remote Repository.

Pull and Fetch will be explained in Chapter 6.

When you run the clone command, you need to specify the URL of the Remote Repository that you want to clone. The URLs for HTTPS and SSH are different. As we explained in Chapter 2, you can choose one of them. You can find the URL of the Remote Repository on the < > Code page of the GitHub web platform. You can see the URLs after clicking the green Code button as shown below.

Where to get a URL of a GitHub repository

When you clone a Remote Repository, the default name of the Remote Repository on your local computer is origin. After you clone a Remote Repository, you can check the Remote Repository name and URL on your computer by running git remote -v.

Practice

skyblue-round-icon.pngDeveloper A (Project Owner Role)

Objective:
Gains access to the project Remote Repository and starts a project as a project member

1. Accept the Remote Repository access invitation

Once the owner of the Remote Repository sends a project member an invitation, the project member will get an email to their registered email address.

In the previous practice, Developer A has sent an invitation to Developer B. In this practice, we'll explain from the Developer B's point of view. After the invitation is sent out, Developer B gets an email like the one below.

Gain access to the project Remote Repository and start a project as a project member: Step 1

Click the View invitation button to see the invitation, and accept the invitation by pressing the Accept invitation button.

Gain access to the project Remote Repository and start a project as a project member: Step 2

You can access the Remote Repository from your GitHub account as a project member.

Gain access to the project Remote Repository and start a project as a project member: Step 3

2. Prepare for GitHub HTTPS or SSH connection

Before executing the git clone command, you need to prepare for GitHub connection with HTTPS or SSH. For HTTPS, you need a PAT. For SSH, you need SSH key pairs and the public key needs to be uploaded to your GitHub platform. If you have not done any of these setups, please check one of the following topic pages. The first one is the easiest and the last one is the most advanced.

  • Generating PAT (Personal Access Token)
  • GitHub SSH Setup

3. Set the current working directory

When you run the git clone command, the project directory and Git Local Repository will be created under the current working directory. Before running the command, you need to set the current directory carefully to create the repository in the right location. In this practice, we use the main project directory for Developer B (e.g., Dev_B_skyblue) under the home directory.

A quick way to open the directory with VS Code is using drag & drop.

Gain access to the project Remote Repository and start a project as a project member: Step 4

Open a new terminal. You can see that the project's main directory is shown in the EXPLORER section on the left and the directory is the current working directory in the terminal.

Gain access to the project Remote Repository and start a project as a project member: Step 5

IdeaTips: Changing and check the current working directory in the command line (the cd and pwd command)

When you open a terminal without selecting a specific directory, the current working directory is usually the home directory. ~ (tilde) is usually used for the home directory path.

Gain access to the project Remote Repository and start a project as a project member: Step 6

If you are not sure, run the command below. The cd command changes your current working directory to the home directory and the pwd command returns the path of your current working directory. The commands below are an example. Use your own project directory path when you run the cd command.

Command Line - INPUT
cd ~/Dev_B_skyblue
pwd

After running the commands, you can confirm your current working directory path as shown below.

Command Line - RESPONSE
/Users/sky-blue/Dev_B_skyblue

4. Clone the repository

To transfer the project directory and repository to your local computer, you need to run the git clone [Remote Repository URL] command.

Command Line - INPUT (for HTTPS)
git clone https://github.com/bloovee/git_practice.git

Or

Command Line - INPUT (for SSH)
git clone git@github.com:bloovee/git_practice.git

If you have successfully authenticated, you'll see a message like the one below.

Command Line - RESPONSE
Cloning into 'git_practice'...
remote: Enumerating objects: 4, done.
remote: Counting objects: 100% (4/4), done.
remote: Compressing objects: 100% (3/3), done.
remote: Total 4 (delta 0), reused 4 (delta 0), pack-reused 0
Receiving objects: 100% (4/4), done.

After this, you can see that the git_practice directory is generated under the current directory.


You can also learn this topic offline. Click AmazonKindle.

More Topics to Explore

Saving and Exiting Vim Editor Normal Mode

Normal Mode (7) – Save and Exit

Understanding Branches in Git with Diagrams

What Is Branch?

Setting Up Docker Environment

Setting Up Docker Environment

Updating Local Repository with git fetch

Get Remote Repository Information to Local Repository – Git Fetch

Searching Phrases in Vim Editor Normal Mode

Normal Mode (5) – Search Phrase

Saving and Exiting Vim Editor Normal Mode

Normal Mode (7) – Save and Exit

Understanding Branches in Git with Diagrams

What Is Branch?

Setting Up Docker Environment

Setting Up Docker Environment

Updating Local Repository with git fetch

Get Remote Repository Information to Local Repository – Git Fetch

Searching Phrases in Vim Editor Normal Mode

Normal Mode (5) – Search Phrase

Tags:

Clone

Git Key Commands

Git & GitHub Introduction
Course Content

Chapter 1. Git & GitHub Overview

What Is Git?

What Is Version Control?

How To Save Versions in Git?

Collaborating on Git & GitHub – Remote Repository

Collaborating on Git & Git Hub – Branch

Git & GitHub Basic Life Cycle

Chapter 2. Git & GitHub Initial Settings

Git & GitHub Initial Settings Overview

Key Tool Preparation (1) – Mac

Key Tool Preparation (2) – Windows

Key Tool Preparation (3) – Linux Remote Server

Git User Settings – git config

Create GitHub Account

GitHub Access Authentication Settings

Generating PAT (Personal Access Token)

GitHub SSH Setup

Chapter 3. Git & GitHub Project Setup

Three Cases in Git & GitHub Project Setup

Git & GitHub Project Setup Overview in Different Cases

Building Remote Collaboration Practice Environment

Project Initiator – Key Steps To Launch Git Project

Project Initiator – Create Local Repository (git init)

Project Initiator – Make the First Commit

Project Initiator – .gitignore File

Project Initiator – Create Remote Repository

Project Initiator – Link Between Remote and Local Repositories (git remote add)

Project Initiator – Upload Local Repository to Remote Repository (git push)

Project Initiator – Grant Remote Repository Access to Project Members

Project Member – Start Project As Collaborator

Project Member – Create Copy of Project Code on Local Computer (git clone)

Non-Member – Start Project With Replica of Existing Repository (Fork)

Fork vs. Clone

Chapter 4. Edit & Commit

Git Regular Workflow – Edit & Commit

Edit and Commit Overview (1)

Add Files to Staging Area – git add

Commit Files – git commit

HEAD and INDEX

Check Status of Working Tree and Staging Area – git status

Check Commit Histories – git log

Check Differences – git diff

Restore Files to Working Tree – git restore

Undo Changes – git reset

Delete Files – git rm

Edit and Commit Overview (2)

Chapter 5. Work With Branches

Git Regular Workflow – Work With Branches

What Is Branch?

Branch Operation Basic Life Cycle

Create Branch and Check Branch Status – Git Branch

Switch Current Branch (1) – Git Checkout

Switch Current Branch (2) – Git Switch

Merge Branches – Git Merge

Fast-Forward Merge

Non-Fast-Forward Merge (No Option)

Non-Fast-Forward Merge (--no-ff Option)

Squash Merge

Rebase Branch – Git Rebase

Managing Conflict

Stash Changes – Git Stash

Chapter 6. Remote Collaboration

Git Regular Workflow – Remote Collaboration

Remote Collaboration Overview

Link With Remote Repository – Git Remote

Upload to Remote Repository – Git Push

Download Remote Repository and Merge to Local Repository – Git Pull

Get Remote Repository Information to Local Repository – Git Fetch

Pull vs. Fetch

Request for Review and Merge – Pull Request

Merge Operation Using GitHub

Chapter 7. Supplemental Topics

Git Key Commands and GitHub Key Features

Git & GitHub Glossary

GitHub Other Features

Chapter 1. Git & GitHub Overview

What Is Git?

What Is Version Control?

How To Save Versions in Git?

Collaborating on Git & GitHub – Remote Repository

Collaborating on Git & Git Hub – Branch

Git & GitHub Basic Life Cycle

Chapter 2. Git & GitHub Initial Settings

Git & GitHub Initial Settings Overview

Key Tool Preparation (1) – Mac

Key Tool Preparation (2) – Windows

Key Tool Preparation (3) – Linux Remote Server

Git User Settings – git config

Create GitHub Account

GitHub Access Authentication Settings

Generating PAT (Personal Access Token)

GitHub SSH Setup

Chapter 3. Git & GitHub Project Setup

Three Cases in Git & GitHub Project Setup

Git & GitHub Project Setup Overview in Different Cases

Building Remote Collaboration Practice Environment

Project Initiator – Key Steps To Launch Git Project

Project Initiator – Create Local Repository (git init)

Project Initiator – Make the First Commit

Project Initiator – .gitignore File

Project Initiator – Create Remote Repository

Project Initiator – Link Between Remote and Local Repositories (git remote add)

Project Initiator – Upload Local Repository to Remote Repository (git push)

Project Initiator – Grant Remote Repository Access to Project Members

Project Member – Start Project As Collaborator

Project Member – Create Copy of Project Code on Local Computer (git clone)

Non-Member – Start Project With Replica of Existing Repository (Fork)

Fork vs. Clone

Chapter 4. Edit & Commit

Git Regular Workflow – Edit & Commit

Edit and Commit Overview (1)

Add Files to Staging Area – git add

Commit Files – git commit

HEAD and INDEX

Check Status of Working Tree and Staging Area – git status

Check Commit Histories – git log

Check Differences – git diff

Restore Files to Working Tree – git restore

Undo Changes – git reset

Delete Files – git rm

Edit and Commit Overview (2)

Chapter 5. Work With Branches

Git Regular Workflow – Work With Branches

What Is Branch?

Branch Operation Basic Life Cycle

Create Branch and Check Branch Status – Git Branch

Switch Current Branch (1) – Git Checkout

Switch Current Branch (2) – Git Switch

Merge Branches – Git Merge

Fast-Forward Merge

Non-Fast-Forward Merge (No Option)

Non-Fast-Forward Merge (--no-ff Option)

Squash Merge

Rebase Branch – Git Rebase

Managing Conflict

Stash Changes – Git Stash

Chapter 6. Remote Collaboration

Git Regular Workflow – Remote Collaboration

Remote Collaboration Overview

Link With Remote Repository – Git Remote

Upload to Remote Repository – Git Push

Download Remote Repository and Merge to Local Repository – Git Pull

Get Remote Repository Information to Local Repository – Git Fetch

Pull vs. Fetch

Request for Review and Merge – Pull Request

Merge Operation Using GitHub

Chapter 7. Supplemental Topics

Git Key Commands and GitHub Key Features

Git & GitHub Glossary

GitHub Other Features