DEV Community

mdidm Infoway
mdidm Infoway

Posted on

Git and GitHub for Beginners: A Simple Guide to Version Control

When you start learning web development or software development, you will quickly come across two important names: Git and GitHub.

Beginners often think Git and GitHub are the same thing, but they are actually different.

Git is a version control system that helps developers track changes in their code, while GitHub is a platform where developers can store, manage, and collaborate on Git repositories.

Whether you are learning JavaScript, React, Node.js, Python, MERN Stack, or another development technology, understanding Git and GitHub is an important skill for your development journey.

Let's understand them step by step.

What Is Git?

Git is a distributed version control system used to track changes in files and source code.

Imagine you are working on a website and make several changes every day.

Without Git, you may have files like:

• website-final
• website-final-new
• website-final-updated
• website-final-latest

This can quickly become difficult to manage.

Git solves this problem by keeping a history of changes.

You can see what changed, when it changed, and who made the change.

What Is Version Control?

Version control is a system that helps developers manage different versions of their projects.

For example, suppose you build a website today.

Tomorrow you change the login functionality, but the new code creates an error.

With version control, you can compare changes and return to an earlier working version.

This makes development safer and more organized.

What Is GitHub?

GitHub is a cloud-based platform that allows developers to host and collaborate on Git repositories.

You can use GitHub to:

• Store your projects
• Share code
• Collaborate with developers
• Track issues
• Review code
• Manage projects
• Showcase your work

Git works on your computer, while GitHub can store your Git repositories online.

Simple Example

Git = Tool for tracking code changes

GitHub = Online platform for storing and collaborating on Git projects

*Why Should Beginners Learn Git and GitHub?
*

Git and GitHub are useful even when you are still a student.

  1. Track Your Changes

Git keeps a history of your project changes.

  1. Recover Previous Versions

If something goes wrong, you can return to an earlier version.

  1. Work With Teams

Multiple developers can work on the same project using branches and collaboration workflows.

  1. Build Your Developer Portfolio

You can upload your projects to GitHub and share your repositories with recruiters.

  1. Learn Professional Development Workflows

Many development teams use Git-based workflows to manage their code.

Basic Git Workflow

A simple Git workflow looks like this:

Create Project

Initialize Git

Make Changes

Check Changes

Commit Changes

Push to GitHub

This workflow becomes easier with regular practice.

Important Git Commands for Beginners

You don't need to memorize hundreds of Git commands.

Start with the basics.

  1. git init

This command initializes a new Git repository.

git init
Enter fullscreen mode Exit fullscreen mode

It creates a Git repository in your project folder.

  1. git status

Use this command to check the current status of your project.

git status
Enter fullscreen mode Exit fullscreen mode

It can show you files that have been modified, added, or are waiting to be committed.

  1. git add

This command adds changes to the staging area.

git add .
Enter fullscreen mode Exit fullscreen mode

The . means you want to stage all changed files in the current directory.

  1. git commit

A commit saves a snapshot of your staged changes.

git commit -m "Add homepage"
Enter fullscreen mode Exit fullscreen mode

A good commit message should clearly describe what you changed.

  1. git log

This command lets you view previous commits.

git log
Enter fullscreen mode Exit fullscreen mode

It is useful when you want to understand the history of your project.

Connecting Git With GitHub

After creating a repository on GitHub, you can connect your local Git project to it.

A common workflow looks like:

git remote add origin YOUR_REPOSITORY_URL
git branch -M main
git push -u origin main
Enter fullscreen mode Exit fullscreen mode

After this, your project can be pushed to the GitHub repository.

What Is a Git Repository?

A repository, often called a repo, is a project tracked by Git.

It contains your project files and the history of changes made to those files.

A repository can be:

• Local
• Remote

Your local repository exists on your computer.

Your GitHub repository is a remote repository hosted online.

What Is a Git Branch?

A branch allows developers to work on a separate version of the code without immediately changing the main codebase.

For example:

main

feature-login

A developer can create a feature branch, work on the login functionality, test it, and later merge it into the main branch.

This becomes especially useful when working in teams.

What Is a Pull Request?

A Pull Request, commonly called a PR, is a way to propose changes to a repository.

For example:

  1. Create a branch
  2. Make changes
  3. Push the branch to GitHub
  4. Open a Pull Request
  5. Review the changes
  6. Merge the changes

Pull Requests are commonly used for code review and collaboration.

Common Git Mistakes Beginners Make

  1. Using Unclear Commit Messages

Avoid messages like:

update
changes
done
final
Enter fullscreen mode Exit fullscreen mode

Instead, use descriptive messages such as:

Add user login validation
Enter fullscreen mode Exit fullscreen mode
  1. Committing Everything Without Checking

Before committing, use:

git status
Enter fullscreen mode Exit fullscreen mode

Review what has changed before creating the commit.

  1. Ignoring .gitignore

Some files should not be uploaded to GitHub.

For example:

• Environment files
• Dependencies
• Build files
• Secret keys

A .gitignore file can help prevent unwanted files from being tracked.

Never commit passwords, API keys, or other sensitive credentials to a public repository.

  1. Working Only on the Main Branch

For larger projects, learning how to use feature branches can make your workflow more organized.

How GitHub Can Help Students

GitHub can be more than just a place to store code.

Students can use it as a developer portfolio.

You can showcase:

• Web development projects
• React applications
• Python projects
• MERN Stack applications
• APIs
• College projects
• Internship projects
• Open-source contributions

A recruiter can look at your repositories and understand what you have actually built.

This can be especially useful for freshers who may not have extensive professional experience.

Simple GitHub Portfolio Tips

If you are using GitHub for your career, focus on quality rather than uploading hundreds of random repositories.

Keep Your Profile Organized

Use clear repository names.

Write Good README Files

Explain:

• What the project does
• Technologies used
• Main features
• How to run it
• Screenshots if useful

Pin Your Best Projects

Highlight your strongest projects on your GitHub profile.

Keep Improving

As you learn new technologies, continue improving your existing projects.

Git and GitHub Learning Roadmap

Beginners can follow this simple path:

Understand Version Control

Install Git

Learn Basic Commands

Create Your First Repository

Make Commits

Create a GitHub Repository

Push Your Project

Learn Branches

Learn Pull Requests

Build Projects

Create Your Developer Portfolio

This gives you a practical foundation for using Git and GitHub.

Conclusion

Git and GitHub are essential tools for modern software development.

Git helps you track and manage changes, while GitHub helps you store, share, and collaborate on projects online.

As a beginner, you don't need to learn everything immediately.

Start with a few basic commands:

git init → git status → git add → git commit → git push

Then gradually learn branches, Pull Requests, collaboration, and professional Git workflows.

The best way to learn Git is not by memorizing commands.

Create a project, make changes, commit them, push them to GitHub, and practice.

The more you use Git in real projects, the more naturally it becomes part of your development workflow.

Start small. Commit often. Keep building.

Top comments (0)