Git vs GitHub: A Comparison for DevOps Engineers

Edvin DsouzaEdvin Dsouza
4 min read

Git and GitHub are two of the most commonly used tools in a DevOps engineer's toolkit. While they are closely related, some key differences between Git and GitHub are important to understand.

What is Git?

Git is an open-source distributed version control system. It tracks changes made to files and coordinates work between multiple people. Git runs locally on your computer and doesn't require a server or internet connection.

Some key features of Git include:

  • Distributed VCS - Every developer has a full copy of the codebase on their machine. This allows to work offline and eliminates single points of failure.

  • Branching and merging - Git makes it easy to create branches to isolate development work without impacting others. Branches can then be merged back into the main codebase.

  • Staging area - Changes are first added to the staging area before being committed to the repository. This allows developers to selectively prepare commits.

  • History and versioning - Git keeps a history of all commits and versions, allowing to revert changes, compare differences, and more.

  • Local operation - Git operates on your local machine. This gives fast performance and the ability to work offline.

Key Concepts:

  • Repository (Repo): A Git repository is a storage space where all your project's files and their history are stored. It can be local (on computer) or remote (on a server).

  • Commit: A commit is a snapshot of project at a specific point in time. It captures changes made to your files.

  • Branch: Branches in Git allow to work on new features or bug fixes without affecting the main project until you're ready to merge your changes.

Here's an example of Git commands:

# Initialize a Git repository
git init

# Add changes to the staging area
git add .

# Commit changes
git commit -m "Initial commit"

# Create a new branch
git branch feature-branch

# Switch to the feature branch
git checkout feature-branch

Git flow workflow - Hotfix Branches

Git workflow - image source: Atlassian

GitHub: The Collaboration Platform

What is GitHub?

GitHub is a cloud-based platform built around the Git version control system. While Git runs locally, GitHub provides a web-based host for Git repositories along with additional collaboration features.

Key features of GitHub include:

  • Remote repositories - GitHub hosts Git repositories online which can be cloned to your local machine.

  • Web-based collaboration - Developers can access repositories through a web interface to view code, commit changes, and more.

  • Code reviews - Pull requests allow developers to review code changes before they are merged.

  • Issue tracking - GitHub provides built-in issue tracking for each repository to coordinate tasks and bugs.

  • Access controls - Fine-grained access controls manage permissions for repositories and collaboration.

  • Graphs and analytics - GitHub provides visualization for commit history, contributors, and repository insights.

GitHub Example

Imagine you want to collaborate with team members on your project. You push your local Git repository to GitHub, create a pull request, and collaborate through issues and discussions. Here's an example:

Push local repository to GitHub:

# Add GitHub as a remote repository
git remote add origin https://github.com/yourusername/yourrepo.git

# Push code to GitHub
git push -u origin main
  1. Create a pull request on GitHub's web interface.

  1. Collaborate with the team through issues and discussions.

    7 unique software collaboration features in GitHub Discussions - The GitHub  Blog

How DevOps Engineers Use Git and GitHub

For a DevOps engineer, Git and GitHub provide powerful version control and collaboration for infrastructure as code and application code. Here are some examples:

  • Use Git locally to track changes to Infrastructure as Code configs for tools like Ansible, Terraform, and Kubernetes.

  • Develop and merge changes to pipelines or Dockerfiles in a DevOps workflow.

  • Maintain configuration repositories on GitHub for better visibility and collaboration with developers.

  • Use GitHub pull requests and reviews to improve infrastructure changes.

  • Leverage GitHub issue tracking and project boards for infrastructure tasks and enhancements.

  • Take advantage of GitHub Actions for continuous integration/continuous deployment (CI/CD) pipelines.

  • Use GitHub insights and graphs to visualize productivity across teams.

Git vs. GitHub: The Bottom Line

In summary, Git is a version control system that tracks changes in code, while GitHub is a web-based platform built around Git that facilitates collaboration and project management. DevOps engineers use Git for version control, enabling them to manage code changes efficiently, while GitHub provides a centralized hub for collaboration, code review, and project organization.

As a DevOps engineer, understanding the distinction between Git and GitHub is crucial. Using Git for version control in local development environment and GitHub for collaboration and sharing your code with others. These tools, when used together effectively, streamline the software development lifecycle and contribute to a successful DevOps workflow.

By mastering both Git and GitHub, DevOps engineers can efficiently manage code, collaborate with team members, and contribute to the continuous improvement of software projects.

2
Subscribe to my newsletter

Read articles from Edvin Dsouza directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Edvin Dsouza
Edvin Dsouza

๐Ÿ‘ฉโ€๐Ÿ’ป DevOps engineer ๐Ÿš€ | Automation enthusiast โš™๏ธ | Infrastructure as code | CI/CD ๐ŸŒŸ Let's build awesome things together!