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.
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.
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.
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"
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.
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.
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.
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
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
A Git repository contains project files along with Git's version control information.
You can create a local repository using:
git init
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.
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.
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.
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.
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.
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.
GitHub provides collaboration features that can be used with Git repositories.
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.
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.
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.
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.
GitHub provides tools for reviewing proposed code changes. Developers can discuss changes and leave comments as part of a pull request.
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.
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.
GitHub Pages is a GitHub service that can publish websites from repositories.
It is commonly used for static websites and documentation.
| 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 |
| 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 |
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.
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
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.
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.
Question: What is the main difference between Git and GitHub?