Git for Beginners: A Simple Guide

Anderson Servat
3 min readJan 28, 2024

--

Git for Beginners: A Simple Guide

Introduction

Welcome to the world of version control! Git is a tool that helps developers like us keep track of changes in our code, work together on projects, and make sure everything runs smoothly. In this beginner-friendly guide, we’ll explore the basics of Git to help you get started on your coding journey.

Step 1: Getting Git

Before we jump into Git, let’s make sure you have it installed on your computer.

  1. Download Git:
  • Visit Git Downloads.
  • Download and install Git based on your operating system.

2. Verify Installation:

  • Open a terminal or command prompt.
  • Type the following command to check if Git is installed:
git --version
  1. If you see a version number, you’re good to go!

Basic Concepts Explained

1. Repository

Think of a repository as a special folder that holds all your code and its history. It’s like a magic box that keeps track of every change you make.

2. Commit

A commit is like taking a snapshot of your code at a specific moment. It’s a way of saying, “Hey, I made some changes, and here they are!” Each commit has a unique ID and a message explaining what you did.

3. Branch

A branch is like a separate playground where you can work on new features without messing up the main code. By default, there’s usually a branch called “main” or “master.”

4. Remote

A remote is like a connection to a server where your code is stored. It could be on a platform like GitHub or GitLab. Remotes help you collaborate with others.

Basic Commands for Beginners

1. Cloning a Repository

To copy a project from a remote server to your computer, use:

git clone <repository_url>

2. Creating a Branch

To start working on a new feature, create a branch:

git checkout -b new_feature

or using the newer git switch:

git switch -c new_feature

3. Making Changes

After making changes to your code, save them and let Git know:

git add .

Then, commit your changes:

git commit -m "Description of what you did"

4. Pushing Changes

To share your changes with others on the remote server:

git push origin your_branch_name

5. Pulling Changes

To get the latest changes made by others:

git pull origin your_branch_name

6. Merging Branches

To bring your changes back to the main code:

git merge your_feature_branch

7. Deleting a Branch

When you’re done with a feature branch:

git branch -d your_feature_branch

Conclusion

Congratulations! You’ve taken your first steps into the Git universe. As you continue your coding adventures, keep exploring more Git features and remember that every developer started as a beginner. Happy coding!

--

--

Anderson Servat

ENTP, dyslexic. Paralegal, Texas Realtor. Back-end Developer. I was a Brazilian attorney, stockbroker, and clown.