To understand the difference between Git and GitHub, we first need to grasp the concept of version control.
Version Control is a system that tracks changes to files over time, creating a historical record of versions. It enables developers to monitor and manage modifications made to source code or other files, supporting collaboration and facilitating effective project management. This system, which manages the versioning of code, is called a Version Control System (VCS).
I. Understanding Git: A Distributed Version Control System
GIT is a distributed version control system primarily used for tracking changes in source code during software development. It monitors code changes, tracks who made those changes, and enables seamless collaboration among team members.
i. Version Control: Git tracks changes to files, allowing developers to revert to previous versions, compare changes over time, and collaborate effectively.
ii. Distributed: Each developer has a complete copy of the repository (repo), including its full history. This enables offline work and faster operations compared to centralized version control systems.
iii. Branching and Merging: Git allows developers to create branches to work on features or fixes independently. Branches can be merged back into the main branch (usually master or main) to incorporate changes.
II. Exploring GitHub: A Collaborative Platform for Developers
GITHUB is a web-based platform built around Git, offering repository hosting, collaboration tools, and project management features to enhance team productivity and code quality.
i. Remote Hosting: GitHub provides a centralized cloud-based platform to host Git repositories. It offers a convenient way to manage, collaborate, and share code with others.
ii. Repositories: A repository (or "repo") is a storage space on GitHub where your project's files, along with their revision history, are stored. It allow multiple collaborators to work on the same project simultaneously.
iii. Integration and Automation: GitHub integrates with various third-party tools and services (CI/CD pipelines, issue trackers, etc.) to automate workflows and streamline development processes.
III. Git vs. GitHub: Key Differences
Aspect | Git | GitHub |
---|---|---|
Primary Function | Distributed version control system | Web-based Git repository hosting service |
Usage | Tracks changes in source code | Hosts repositories, facilitates collaboration |
Local/Remote Access | Works locally and can be used offline | Requires internet for remote repository access |
Features | Committing changes, branching, merging | Pull requests, issue tracking, project boards |
Community | Core tool used by developers globally | Platform for open-source collaboration |
Integration | Used independently or with other hosting services | Integrates with CI/CD pipelines, third-party tools |
Accessibility | Available on command line and various GUI tools | Accessed via web interface |
Cost | Free and open-source | Offers free public repositories, paid plans for private |
IV. Installing Git on Your Machine
i. For Linux using Package Manager:
- Open Terminal.
- For Debian-based distributions (e.g., Ubuntu):
sudo apt-get update
sudo apt-get install git -y
- For Red Hat-based distributions (e.g., Fedora):
sudo dnf update
sudo dnf install git -y
ii. Verifying Git Installation:
- Open Terminal and type the following command and press Enter:
git --version
- We should see the installed version of Git displayed.
iii. Configuring Git for the first time:
- Setting up Git with our identity:
git config --global user.name "Your Name"
git config --global user.email "your.email@example.com"
iv. Verifying the configuration:
git config --list
V. Setting Up Your GitHub Account
i. Visit GitHub:
- Go to GitHub website.
ii. Sign Up:
- Click on the Sign up button located at the top right corner of the page.
iii. Create Account:
- Enter your email address, create a password, and choose a username.
- Verify your email address by clicking the link sent to your email.
iv. Personalize Account:
- Optionally, fill out additional information like whether you want to receive updates from GitHub, and set your preferences.
v. Finish Setup:
- Complete the CAPTCHA to verify you're not a robot.
- Click on Create account.
vi. Choose a Plan:
- Select the free plan unless you need the features of a paid plan.
vii. Setup:
- Follow the on-screen instructions to set up your profile and preferences.
VI. Create Your First GitHub Repository
i. Create GitHub Repository:
- Log in to GitHub
- Click on the + icon in the top right corner / select Create Repository.
- Fill in the repository details (name, description, visibility, README) and click Create repository.
ii. Clone the Repository to Your Local Machine:
- Open Command Prompt or Terminal.
- Clone the repository using:
git clone https://github.com/your-username/my-first-repo.git
- Navigate to the repository directory:
cd my-first-repo
iii. Create and Add a New File:
- Create a new file in the repository directory:
echo "Hello, World!" > hello_world.txt
- Add the file to the staging area:
git add hello_world.txt
iv. Commit Your Changes:
- Commit the changes with a descriptive message:
git commit -m "Add hello_world.txt"
v. Push Your Changes to GitHub:
- Push the committed changes to your GitHub repository:
git push origin main
Git - GitHub: How it works
Key Concepts:
Working Directory: The local directory where you make changes to your files.
Staging Area: An intermediate area where you prepare changes before committing them.
Local Repository: The versioned history of your project stored on your local machine.
Remote Repository: A versioned history of your project stored on a server, accessible over the internet.
Git Commands
git add: Adds changes from the working directory to the staging area.
git commit: Records the staged changes in the local repository with a descriptive message.
git push: Sends committed changes from your local repository to a remote repository.
git fetch: Retrieves updates from the remote repository without merging them into your local branch.
git merge: Combines changes from different branches into your current branch.
git pull: Fetches updates from the remote repository and merges them into your local branch.
git clone: Creates a local copy of an existing remote repository.
git checkout: Switches to a different branch or restores files to a previous state.
Additional resources and references for further learning.
Git Documentation Here
GitHub Documentation Here
Top comments (0)