[ALT TEXT FOR IMAGE]

How Git & GitHub Work Together

Hey There, welcome back or welcome to The Dev Anvil, where we’re always forging better code. If you've noticed things have been a little quiet at The Dev Anvil recently. If you're seeing this post, thank you for sticking around! I took a necessary pause to focus on some intense professional projects, and I genuinely appreciate your patience. While the site was quiet, I was gaining new, real-world development insights that I'm now eager to share. I'm excited to be back in the swing of things, and I promise to make up for the silence by delivering high-quality, practical content, starting with this post!

In our last post, we discussed the foundational concept of Version Control Systems (VCS) and why they are essential for tracking changes, enabling collaboration, and providing a safety net for any modern project.

Today, we're diving into the tools that bring that concept to life: Git and GitHub. While Git is the powerful, free, and open-source version control system that runs locally on your computer (acting as a "time machine" for your code ), GitHub is the popular cloud-based platform that provides the online infrastructure, collaboration features, and remote repository hosting. Together, these two tools are fundamental to modern software development, and understanding how they work in tandem is the key to efficient teamwork and project management.


Git: The Version Control System

Git is a free, open-source version control system (VCS) that runs locally on your computer. Its primary purpose is to track changes in files and projects over time. Imagine it as a "time machine" for your code.


Key Git Commands:


GitHub: The Cloud-Based Collaboration Platform

GitHub is a popular cloud-based platform that hosts Git repositories and provides a web-based interface for managing and collaborating on projects. It leverages Git's capabilities and adds features for teamwork and project management.


Key GitHub Features for Collaboration:

  1. Forks: A fork is a personal copy of a repository that lives on your GitHub account, allowing you to experiment freely without affecting the original project.

  2. Pull Requests (PRs): A pull request is a proposal to merge changes from your branch (or fork) into another branch (e.g., the main branch). This allows collaborators to review and discuss code before it is integrated.

A Basic Git & GitHub Workflow

In the last post, I talked about how to install Git on your computer, how to initialize a repository and how to connect that local repository to a remote host (e.g GitHub). Now I’m going to show you a basic Git & GitHub Workflow.

A common basic workflow for combining local Git development with remote GitHub hosting involves these steps:

  1. Create a Repository on GitHub
    • Action: Start by creating an empty repository on the GitHub website.

  2. Clone the Repository to your local machine (i.e your PC)
    • Command: This downloads the remote repository and initializes the local Git environment.
    •      git clone 'repository-url'

  3. Make changes to files in your local working directory.
    • Action: Edit, create, or delete files in the project folder.

  4. Stage the changes.
    • Command: This selects which changes will be included in the next snapshot (commit).
    •      git add .

  5. Commit the changes locally.
    • Command: This records the staged changes as a new snapshot in your local history.
    •      git commit -m "Description of changes"

  6. Push the committed changes to GitHub.
    • Command: This synchronizes your local history with the remote repository on GitHub, making the changes accessible to others and serving as a crucial remote backup.
    •      git push origin main

The Synergy: Git and GitHub in Action


Conclusion

In essence, you've learned that Git and GitHub represent the ultimate partnership in modern software development. Git is the robust, local engine — your personal time machine, meticulously tracking every snapshot, branch, and commit. GitHub is the collaborative cloud platform that elevates that engine, providing the critical infrastructure for remote backup, professional code review via Pull Requests, and seamless teamwork.

You now possess the fundamental knowledge required to adopt the standard, collaborative workflow of every professional developer. Mastering the basic cycle — local commits, remote pushes, and managing changes via a remote repository — is the key to working on large projects, contributing to open source, and ensuring you never lose a single line of code again.

Thank you for reading and have a wonderful rest of your day. 👋


← Back to all posts