Git and GitHub Explained: A Complete Visual Guide for Absolute Beginners
“Everything you need to know about tracking your code and sharing it with the world, simplified.”
Let’s be honest. When you first start coding, the world is full of complicated words. You’re trying to learn a language, and then people start saying things like “Git” and “GitHub” as if they are the most natural things in the world.
You might feel a little overwhelmed. It sounds technical, and it seems like everyone else already knows it.
But honestly: Git and GitHub are simple. The core concepts are powerful, but the ideas behind them are incredibly intuitive. They are the ultimate tools for building, managing, and collaborating on any code project.
Fact: Git was created in 2005 by Linus Torvalds, the same person who created the Linux operating system kernel.
A Simple Analogy: Git vs. GitHub
This is the most common point of confusion. What’s the difference? They sound the same!
Think of it like this:
You can use a camera (Git) without ever uploading a single photo online. But if you want to back them up, show them to friends, or work on them with a team, you need a place to put them (GitHub).
In technical terms:
Git is an acronym for Global Information Tracker. Git is a Version Control System (VCS); A source tool that helps in tracking and managing codes.
GITHUB to GIT is the same as a photograph is to a person. It provides a graphical user interface to the command line tool GIT. GitHub is a web-hosting service that allows one to host Git repositories.
Key Terms You Need to Know
Let’s quickly define a few words that you will see all the time.
- Repository (or “Repo”): A fancy word for your project folder. This is where your code, images, and other project files live.
- Commit: Think of this as a saved state for your project. When you make a commit, you’re taking a snapshot of your files in their current condition.
- Branch: A parallel universe for your project. You can make a branch to try a new idea without affecting the main, working version of your code.
- Pull Request (PR): When you’ve finished a change on your branch and you want to merge it back into the main project, you make a pull request. It’s like asking your team to review your work and approve it.
- Remote: A copy of your repository that’s not on your computer. Your GitHub repo is a “remote” repository.
Getting Started: The Essential Setup
Install Git
This is the tool for your computer. Go to the official Git download page and follow the installation instructions for your operating system. (For Mac users, you can also use Homebrew, a popular package manager).
Create a GitHub Account
If you don’t have one, go to GitHub.com and sign up.
Configure Git
You need to tell Git who you are. This information will be attached to every “snapshot” you take. Run these two commands on your computer’s command line (Terminal on Mac, Command Prompt or PowerShell on Windows) replacing with your information:
git config --global user.name "Your Name"
git config --global user.email "your.email@example.com"Create a New Project: From Scratch
You can either create a new repository or make an existing project a Git repository. Let’s create a new repository:
Open your command line. Navigate to the directory where you want to create your new project. Create a new folder for your project and enter it:
mkdir git-demo-project
cd git-demo-projectTurn this folder into a Git repository. This will initialise a new Git repository.
git initThis command tells Git to start tracking changes in this folder. It’s like turning on the recording feature on your camera.
Excellent! You created a local Git repository.
Making Changes and Saving (Committing)
Now, let’s create a file and save its current state. The workflow you’re about to learn is the core of Git.
Get Payal Makwana’s stories in your inbox
Join Medium for free to get updates from this writer.
Create a simple text file. You can use your favorite code editor. Let’s create a file called README.md and add a line of text like "My first Git project!"
Check the status of your project.
git statusYou’ll see your README.md file listed as an "untracked file". Git knows it’s there, but it’s not part of a snapshot yet.
Add the file to the “staging area.” This is like asking the photographer to frame the shot. You’re telling Git, “I want this file to be in the next snapshot.”
git add README.mdCommit the file. This takes the actual snapshot. This command creates a permanent record of the state of your project.
git commit -m "Add README file with initial content"The -m stands for "message". This message is essential. It's a short, descriptive note explaining what you changed and why. Future you will thank you.
Branching: Experimenting with Project
This is one of the most powerful features of Git. Let’s say you want to try out a new feature for your project, like adding a new section to your README file, but you don’t want to break the working version of your code. You create a branch.
Create a new branch
git checkout -b new-featureThe checkout command moves you between branches. The -b flag means "create a new branch with this name and switch to it."
Make your changes. Let’s modify your README.md file and add another line of text like "This is a new section I'm testing."
Go through the workflow. Just like before: stage your changes and commit them.
git add README.md
git commit -m "Add new section to README for testing"Now, these changes exist only on the new-feature branch. The main version of your project is untouched.
GitHub: Pushing Your Work Online
Ready to upload your snapshots?
This connects your local Git repository to a remote repository on GitHub.
Create a new repository on GitHub
Login to your GitHub and go to github.com/new. Give it a name (it can be the same as your local folder) and you can choose visbility as public or private.
Connect your local repository to your new GitHub remote
GitHub will give you a list of commands. Copy the one that starts with git remote add origin. It should look something like this:
git remote add origin https://github.com/your-username/my-first-git-project.git
git branch -M mainThis command tells your local Git, “The remote repository named ‘origin’ is at this web address.”git branch -M mainwill change its default branch name from master to main.
Push your local changes to GitHub
You can push the main branch of your project online.
git push -u origin mainThe -u flag is for the first time you push. It sets up a tracking connection, making future pushes simpler with just git push. (If your main branch is called master, use git push -u origin master instead).
Conclusion: What’s Next?
Congratulations! You’ve just mastered the fundamental workflow of Git and GitHub. You can create a project, save its state, experiment on a new branch, and upload it all to the cloud for safekeeping and collaboration. By making your first commit and pushing it to GitHub, you’ve officially joined a global community of creators.
You’ve learned to “push” changes to your own remote repository. Now you can learn about cloning a team member’s repository, creating a branch to work on a task, and then submitting a Pull Request to have your changes reviewed and merged. This is how almost all software is built.








