Lesson 3 of 60 – Git vs GitHub
5%

Git vs GitHub

Git and GitHub are closely related technologies, but they are not the same thing. Git is a version control system, while GitHub is an online platform used to host Git repositories and support collaboration.

Note: You can use Git without GitHub. GitHub is one of the platforms that can host repositories managed with Git.

1. What is Git?

Git is a distributed version control system. It is software that runs on your computer and tracks changes in your project files.

git --version

Git provides commands for creating repositories, making commits, creating branches and managing changes.

2. What is GitHub?

GitHub is an online platform that provides hosting for Git repositories and tools for collaboration and software development.

A Git repository can be stored on GitHub so that developers can share and collaborate on the project.

3. Git is Software

Git is software that you install on your computer. It provides command-line tools and can also be used through various graphical applications.

For example:

git status
git add .
git commit -m "Update project"

4. GitHub is an Online Platform

GitHub provides online services around Git repositories. A repository hosted on GitHub can be accessed by authorized users over the internet.

GitHub also provides features for collaboration, code review, project management and automation.

5. Git Can Work Without GitHub

You do not need a GitHub account to create a Git repository and make commits locally.

git init
git add .
git commit -m "Initial commit"

These commands can be performed on a local computer without GitHub.

6. GitHub Uses Git Repositories

GitHub can host repositories that use Git for version control. This allows developers to keep a remote copy of their repository and collaborate with others.

7. Git is Local

Git operations can be performed locally on your computer. For example, you can create commits and inspect history without sending those operations to GitHub.

git log

8. GitHub is Remote

GitHub can act as a remote location for your Git repository. You can send local commits to a GitHub repository using Git commands.

git push

9. Git Repository

A Git repository contains project files along with Git's version control information.

You can create a local repository using:

git init

10. GitHub Repository

A GitHub repository is a repository hosted on GitHub. It provides an online location for storing and collaborating on a Git-based project.

A GitHub repository can be connected to a local Git repository.

11. Connecting Git to GitHub

A local Git repository can be connected to a GitHub repository using a remote URL.

git remote add origin https://github.com/username/project.git

Here, origin is a commonly used name for the remote.

12. Sending Code to GitHub

After creating local commits, you can send them to a configured GitHub remote using:

git push origin main

This transfers commits from the local repository to the remote repository.

13. Getting Changes from GitHub

Git can retrieve changes from a remote repository. One common command is:

git pull origin main

This gets remote changes and integrates them into the current branch, subject to the repository state and Git's merge/rebase configuration.

14. Git Clone and GitHub

You can clone a GitHub repository to your computer using git clone.

git clone https://github.com/username/project.git

This creates a local copy of the remote repository.

15. Git Commit

A Git commit records a set of staged changes in the local repository.

git add .
git commit -m "Add login page"

The commit exists in the local Git history until it is shared with a remote repository.

16. GitHub and Collaboration

GitHub provides collaboration features that can be used with Git repositories.

  • Repository sharing
  • Pull requests
  • Issues
  • Code reviews
  • Team collaboration

17. Git Branches

Branches are a Git feature used to maintain separate lines of development.

git branch feature-login

Branches can also be pushed to a remote GitHub repository.

18. Pull Requests on GitHub

A pull request is a GitHub feature used to propose changes to a repository and facilitate discussion and review before those changes are integrated.

Pull requests commonly work with Git branches.

19. Git Merge

Git provides the merge command for combining changes from different branches.

git merge feature-login

GitHub can provide interfaces for reviewing and merging changes through pull requests.

20. GitHub Issues

GitHub Issues can be used to track tasks, bugs, feature requests and other work related to a repository.

Issues are a GitHub collaboration feature rather than a Git command.

21. GitHub Code Review

GitHub provides tools for reviewing proposed code changes. Developers can discuss changes and leave comments as part of a pull request.

22. GitHub README

A GitHub repository can contain a README.md file. It is commonly used to explain what a project does and how to use it.

# My Project

This project demonstrates Git and GitHub.

23. GitHub Actions

GitHub Actions is a GitHub feature for automating workflows such as building, testing and deploying software.

Workflows are commonly defined using YAML files in a repository.

24. GitHub Pages

GitHub Pages is a GitHub service that can publish websites from repositories.

It is commonly used for static websites and documentation.

25. Git vs GitHub Commands

Git Command Purpose
git init Create a Git repository
git add Stage changes
git commit Record changes
git push Send commits to a remote repository
git pull Get and integrate remote changes
git clone Create a local copy of a repository

26. Git vs GitHub Comparison

Git GitHub
Version control software Online platform for Git repositories
Runs locally Provides online repository hosting
Tracks project history Hosts and collaborates on repositories
Provides Git commands Provides web-based collaboration features
Can work without GitHub Works with Git repositories

27. Simple Git and GitHub Workflow

Create Project
      ↓
git init
      ↓
git add .
      ↓
git commit
      ↓
Create GitHub Repository
      ↓
Connect Remote
      ↓
git push
      ↓
Repository on GitHub

This is a simplified example of how a local Git project can be shared through GitHub.

28. Can You Use Git Without GitHub?

Yes. Git can be used independently on your computer. You can create repositories, make commits, create branches and inspect history without using GitHub.

git init
git add .
git commit -m "First commit"
git log

29. Can You Use GitHub Without Learning Git?

GitHub provides graphical and web-based features, but understanding Git concepts and commands is very useful when working with repositories, branches, commits, merges and remote changes.

Learning Git first provides a strong foundation for understanding how GitHub repositories work.

30. Git and GitHub in Real Projects

In a typical development project, Git can manage the local version history while GitHub can provide remote repository hosting and collaboration tools.

For example:

Developer Computer
       |
       | Git
       ↓
Local Repository
       |
       | git push
       ↓
GitHub Repository
       |
       | Collaboration
       ↓
Team Members

Understanding the difference between Git and GitHub is an important foundation for the lessons that follow.

📌 Key Points

  • Git is a distributed version control system.
  • GitHub is an online platform for hosting Git repositories and collaboration.
  • Git can be used without GitHub.
  • A Git repository can be stored locally on your computer.
  • A GitHub repository can act as a remote repository.
  • git push sends local commits to a remote repository.
  • git pull gets and integrates remote changes.
  • git clone creates a local copy of a remote repository.
  • Git provides branches, commits and merging.
  • GitHub provides features such as pull requests, issues and code review.

🧠 Quick Quiz

Question: What is the main difference between Git and GitHub?