Git Remote Repositories & GitHub: Complete Guide to Cloning and Online Git Services for Beginners

Learn Git remote repositories with real examples. Master GitHub account setup, repository creation, cloning, and understand the difference between local and remote Git repositories with detailed terminal output.

16 min read

Ready to take your Git skills beyond local repositories? After mastering Git installation and setup, it's time to explore the collaborative power of remote repositories. This tutorial demonstrates real GitHub workflows with detailed terminal output, explaining every step for absolute beginners.

💡

🎯 What You'll Learn: In this comprehensive guide, you'll discover:

  • What remote repositories are and why they're essential
  • Different types of Git hosting services and their purposes
  • Step-by-step GitHub account setup and repository creation
  • How to clone repositories from GitHub to your local machine
  • Understanding the relationship between local and remote repositories
  • Real terminal sessions with detailed explanations of every command and output
  • The difference between public and private repositories

Prerequisites: Basic Git knowledge from previous tutorials in this series

🌐 Understanding Remote Repositories

What Are Remote Repositories?

A remote repository is a Git repository hosted on a server (either online or on a local network) that multiple developers can access. Think of it as the "central hub" where teams collaborate and share code.

Key Concepts:

Local Repository: Git repository on your personal computer

  • Only you can access it directly
  • Where you make changes and commits
  • Acts as your personal workspace

Remote Repository: Git repository hosted on a server

  • Accessible to multiple team members
  • Serves as the "source of truth" for the project
  • Enables collaboration and code sharing

Analogy: Think of it like a shared Google Drive folder:

  • Local Repository = Files on your computer
  • Remote Repository = Shared folder everyone can access
  • Syncing = Uploading/downloading changes between local and remote

Types of Git Hosting Services

Service TypeExamplesBest For
Online Git ServicesGitHub, GitLab, BitbucketOpen source projects, team collaboration
Local Git ServerGitLab self-hosted, Gitea, GitoliteCorporate environments, privacy-sensitive projects
Cloud EnterpriseGitHub Enterprise, GitLab EnterpriseLarge organizations with compliance needs

Why Choose GitHub?

For this tutorial series, we'll use GitHub because it's:

  • Most Popular: Used by millions of developers worldwide
  • Free Tier: Generous free plan for personal and small team use
  • Great Documentation: Excellent learning resources and community
  • Industry Standard: Many employers expect familiarity with GitHub
  • Rich Features: Issues, pull requests, GitHub Actions, and more

🚀 Setting Up Your GitHub Account

Creating Your GitHub Account

  1. Visit GitHub: Go to github.com
  2. Sign Up: Click "Sign up" and choose your username carefully
  3. Verify Email: Check your email and verify your account
  4. Choose Plan: Select the free plan (sufficient for learning)

Username Tips:

  • Choose something professional (you might use this for job applications)
  • Avoid spaces, special characters, or overly complex names
  • Consider using variations of your real name
  • Remember: you can change it later, but it affects all your repository URLs

Understanding Repository Visibility

GitHub offers two main visibility options:

Repository TypeWho Can See ItBest For
Public RepositoryAnyone on the internetOpen source projects, portfolios, learning projects
Private RepositoryOnly you and people you explicitly invitePersonal projects, proprietary code, early development

📝 Creating Your First GitHub Repository

Step-by-Step Repository Creation

  1. Login to GitHub: Navigate to your GitHub homepage
  2. Find the New Repository Button: Look for the "+" icon in the top-right corner
  3. Click the Dropdown: Select "New Repository" from the menu
  4. Fill Repository Details:
    • Repository Name: firstdemoproject
    • Description: This is my first demo project
    • Visibility: Choose "Public" for learning purposes
    • Initialize: Check "Add a README file"
  5. Create: Click "Create repository"
💡

💡 UI Evolution Note: GitHub's interface evolves over time. If the exact buttons or layout look different, use common sense to find similar options. The core functionality remains the same.

Understanding the README File

The README.md file is crucial for every repository:

README Purpose:

  • Project Description: Explains what the project does
  • Installation Instructions: How to set up and run the project
  • Usage Examples: How to use the software
  • Contributing Guidelines: How others can contribute
  • Contact Information: How to reach the maintainers

Markdown Format: README files use .md extension (Markdown), which allows formatted text, links, images, and code blocks.

Getting Your Repository URL

After creating the repository:

  1. Find the Code Button: Look for the green "Code" button on your repository page
  2. Click to Open: This reveals the repository URL options
  3. Copy HTTPS URL: Copy the URL that looks like: https://github.com/username/firstdemoproject.git

The URL structure: https://github.com/[username]/[repository-name].git

💻 Cloning Your First Repository

Preparing Your Local Environment

Let's follow the exact terminal session to clone the repository:

[centos9@vbox myproject 01:44:04]$ cd ..

Command Explanation:

  • cd .. - Move up one directory level
  • Purpose: Navigate from the current project to the parent directory where we want to store our new cloned repository

The Git Clone Command

Now let's clone the repository we just created on GitHub:

[centos9@vbox Repo 01:44:06]$ git clone https://github.com/owais-io/firstdemoproject.git
Cloning into 'firstdemoproject'...
remote: Enumerating objects: 3, done.
remote: Counting objects: 100% (3/3), done.
remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 0 (from 0)
Receiving objects: 100% (3/3), done.

Command Breakdown:

  • git clone - The Git command to copy a remote repository
  • https://github.com/owais-io/firstdemoproject.git - The URL of the remote repository
  • Purpose: Download the entire repository from GitHub to your local machine

Understanding Clone Output

Let's analyze each line of the clone output:

Output LineMeaningWhat's Happening
Cloning into 'firstdemoproject'...Creating local directoryGit is creating a folder with the repository name
remote: Enumerating objects: 3Counting repository contentsGitHub is listing all objects (files, commits) to transfer
remote: Counting objects: 100% (3/3)Progress indicatorAll 3 objects identified and ready to transfer
remote: Total 3 (delta 0, reused 0)Transfer summary3 total objects, no compressed differences, no reused objects
Receiving objects: 100% (3/3), done.Download completeAll objects successfully downloaded to your local machine

Verifying the Clone

Let's check what was created:

[centos9@vbox Repo 01:44:27]$ ls -ahl
total 0
drwxr-xr-x. 4 centos9 centos9  47 Sep 26 01:44 .
drwxr-xr-x. 4 centos9 centos9  32 Sep 23 00:30 ..
drwxr-xr-x. 3 centos9 centos9  35 Sep 26 01:44 firstdemoproject
drwxr-xr-x. 3 centos9 centos9 105 Sep 25 19:15 myproject

What We See:

  • firstdemoproject - New directory created by Git clone
  • myproject - Our previously created local repository
  • Both directories exist in the same parent folder

Exploring the Cloned Repository

[centos9@vbox Repo 01:44:39]$ cd firstdemoproject/

[centos9@vbox firstdemoproject 01:44:46]$ ls
README.md

[centos9@vbox firstdemoproject 01:44:47]$ ls -ahl
total 4.0K
drwxr-xr-x. 3 centos9 centos9  35 Sep 26 01:44 .
drwxr-xr-x. 4 centos9 centos9  47 Sep 26 01:44 ..
drwxr-xr-x. 8 centos9 centos9 163 Sep 26 01:44 .git
-rw-r--r--. 1 centos9 centos9  49 Sep 26 01:44 README.md

Key Observations:

  • README.md - The file we created on GitHub is now local
  • .git folder - Complete Git repository structure was copied
  • File size: README.md is 49 bytes (contains the repository description)

🔍 Understanding Local vs Remote Repository Status

Checking Repository Status

[centos9@vbox firstdemoproject 01:44:49]$ git status
On branch main
Your branch is up to date with 'origin/main'.

nothing to commit, working tree clean

Breaking Down the Status Output

Status LineMeaningSignificance
"On branch main"Currently on main branchGitHub uses 'main' as default branch name
"up to date with 'origin/main'"Local and remote are synchronizedYour local repository matches GitHub exactly
"nothing to commit, working tree clean"No uncommitted changesWorking directory is pristine, ready for development
💡

💡 Important Terminology:

  • origin = The default name for the remote repository (GitHub in our case)
  • origin/main = The main branch on the remote repository
  • main = Your local main branch

📁 Making Your First Changes

Creating a New File

Let's add a new file to our cloned repository:

[centos9@vbox firstdemoproject 01:44:57]$ touch first.txt

Command Explanation:

  • touch first.txt - Create an empty file named first.txt
  • Purpose: Create a new file to demonstrate Git workflow with remote repositories

Adding Content to the File

[centos9@vbox firstdemoproject 01:45:36]$ cat <<EOF > first.txt
> hello world
> EOF

Command Breakdown:

  • cat <<EOF > first.txt - Here document syntax to write text to file
  • > hello world - The content being written
  • > EOF - End marker for the here document
  • Purpose: Add content to our new file using terminal input

Verifying File Content

[centos9@vbox firstdemoproject 01:45:58]$ cat first.txt
hello world

Command Explanation:

  • cat first.txt - Display the contents of the file
  • Output: Shows "hello world" as expected
  • Purpose: Confirm the file was created with correct content

📊 Tracking Changes with Git Status

Status After Adding New File

[centos9@vbox firstdemoproject 01:46:02]$ git status
On branch main
Your branch is up to date with 'origin/main'.

Untracked files:
  (use "git add <file>..." to include in what will be committed)
	first.txt

nothing added to commit but untracked files present (use "git add" to track)

Understanding File Status Types

StatusMeaningNext Action
UntrackedGit doesn't know about this fileUse git add to start tracking
StagedChanges ready to be committedUse git commit to save changes
ModifiedTracked file has been changedUse git add to stage changes
CommittedChanges saved in Git historyUse git push to share with remote

Staging the New File

[centos9@vbox firstdemoproject 01:46:07]$ git add .

Command Explanation:

  • git add . - Add all untracked and modified files to the staging area
  • Purpose: Prepare changes for commitment
  • Alternative: Could use git add first.txt to add only the specific file

Status After Staging

[centos9@vbox firstdemoproject 01:46:35]$ git status
On branch main
Your branch is up to date with 'origin/main'.

Changes to be committed:
  (use "git restore --staged <file>..." to unstage)
	new file:   first.txt

Key Changes:

  • "Changes to be committed" - File is now staged
  • "new file: first.txt" - Git recognizes this as a new file
  • Unstaging hint - Git suggests how to undo staging if needed

💾 Committing Changes

Creating Your First Commit

[centos9@vbox firstdemoproject 01:46:39]$ git commit -m "add first.txt"
[main fd109ec] add first.txt
 1 file changed, 1 insertion(+)
 create mode 100644 first.txt

Command Breakdown:

  • git commit -m "add first.txt" - Create commit with message
  • -m flag: Specify commit message inline
  • Commit message: Brief description of what was changed

Understanding Commit Output

Output ComponentExampleMeaning
Branch and Commit Hash[main fd109ec]Commit created on main branch with hash fd109ec
Commit Messageadd first.txtThe descriptive message you provided
Change Summary1 file changed, 1 insertion(+)Statistics about what was modified
File Actioncreate mode 100644 first.txtNew file created with standard permissions

Status After Commit

[centos9@vbox firstdemoproject 01:46:54]$ git status
On branch main
Your branch is ahead of 'origin/main' by 1 commit.
  (use "git push" to publish your local commits)

nothing to commit, working tree clean

Critical Status Change:

  • "ahead of 'origin/main' by 1 commit" - Your local repository now has changes that GitHub doesn't have
  • Suggestion: Git recommends using git push to synchronize with remote
  • Clean working tree: All changes are committed, ready for more work
⚠️

⚠️ Important Understanding: After committing locally, your changes exist only on your computer. GitHub still doesn't have your new file! You need to "push" to send changes to the remote repository.

🎯 Key Takeaways

✅ Essential Concepts Mastered

  1. Remote Repositories: Understand the difference between local and remote Git repositories

  2. GitHub Setup: Created account, repository, and understand public vs private repositories

  3. Git Clone: Successfully cloned a repository from GitHub to local machine

  4. File States: Learned about untracked, staged, and committed file states

  5. Local vs Remote Status: Understand what "ahead of origin/main" means

  6. Repository Structure: Cloned repository includes complete .git folder and working files

  7. Branch Terminology: Difference between 'main', 'master', and 'origin/main'

🚀 What's Next?

In the next tutorial, we'll complete the collaboration workflow by learning:

  • How to push local changes to GitHub
  • Understanding authentication with personal access tokens
  • Pulling changes made by others (or through GitHub's web interface)
  • The difference between git fetch, git merge, and git pull
  • Managing multiple commits and understanding commit history

🎉 Congratulations! You have successfully:

  • ✅ Set up a GitHub account and created your first repository
  • ✅ Understood the concept of remote repositories
  • ✅ Cloned a repository from GitHub to your local machine
  • ✅ Made changes and committed them locally
  • ✅ Learned about local vs remote repository states

You're now ready to learn about pushing changes and collaborating with others!

💬 Discussion

How did your first experience with GitHub and cloning go?

  • Did you encounter any issues creating your GitHub account or repository?
  • What was most surprising about the clone process?
  • Do you understand the relationship between your local repository and the GitHub repository?
  • What questions do you have about remote repositories or the collaboration workflow?

📋 Command Cheat Sheet

CommandPurposeExample
git clone <url>Copy remote repository to local machinegit clone https://github.com/user/repo.git
git statusCheck repository state and file statusgit status
git add .Stage all changes for commitgit add .
git commit -m "message"Save staged changes with descriptiongit commit -m "add new feature"
touch <filename>Create empty filetouch newfile.txt
cat <filename>Display file contentscat readme.txt
Owais

Written by Owais

I'm an AIOps Engineer with a passion for AI, Operating Systems, Cloud, and Security—sharing insights that matter in today's tech world.

I completed the UK's Eduqual Level 6 Diploma in AIOps from Al Nafi International College, a globally recognized program that's changing careers worldwide. This diploma is:

  • ✅ Available online in 17+ languages
  • ✅ Includes free student visa guidance for Master's programs in Computer Science fields across the UK, USA, Canada, and more
  • ✅ Comes with job placement support and a 90-day success plan once you land a role
  • ✅ Offers a 1-year internship experience letter while you study—all with no hidden costs

It's not just a diploma—it's a career accelerator.

👉 Start your journey today with a 7-day free trial

Related Articles

Continue exploring with these handpicked articles that complement what you just read

More Reading

One more article you might find interesting