- Published on
Get Started with Git Your First Steps to Version Control
- Authors

- Name
- Gabriel
- @gabriel__xyz
If you’re new to software development, you've probably heard about Git. So, what is it? At its core, Git is a tool that tracks changes to your project files over time.
Forget about messy file versions like project_final_v3.docx. Git creates clean, historical "snapshots" of your work. This lets you rewind to any point in your project’s history with a simple command, making it an indispensable safety net and collaboration tool.
Why Git Is Essential for Modern Developers

Before we jump into the commands, let’s talk about why Git is a non-negotiable skill for anyone building software. Git is a version control system, but what does that mean for your day-to-day work? It means you can code with confidence, knowing you have a complete and reliable history of every single change made.
Imagine you're building a website and want to experiment with a new navigation bar. Without Git, you might copy your entire project folder, which quickly becomes confusing. With Git, you just create a new "branch"—think of it as a parallel timeline. You can build and test the new feature there without touching the stable, working version of your site.
If the experiment fails? Just delete the branch. No harm done. If it works? You can merge your changes back into the main project seamlessly.
The Power of Distributed Version Control
Git is specifically a distributed version control system (DVCS), and this is a game-changer. Unlike older systems that relied on a central server, a DVCS gives every developer a full copy of the project history on their local machine. This has some huge advantages:
- Work Offline: You can commit changes, browse history, and create branches without an internet connection. You only need to be online to share your work with others.
- Blazing Speed: Since the entire repository is on your local drive, most operations—like checking file differences or viewing history—are lightning-fast.
- Built-in Backups: Every team member's local copy is a full-fledged backup. If the main server (like GitHub) goes down, the project’s history is safe and sound on multiple computers.
Git was created by Linus Torvalds back in 2005 to manage the development of the Linux kernel. He designed it for speed, data integrity, and to support distributed, non-linear workflows. It has since become the standard for version control worldwide, allowing developers to collaborate from anywhere. You can dive deeper into Git development statistics from hutte.io.
A Universal Language for Collaboration
Ultimately, getting started with Git is about learning the language of modern software collaboration. It’s the foundation for tools like GitHub, GitLab, and platforms like PullNotifier.
Mastering Git lets you contribute to open-source projects, work effectively in a team, and maintain a clean, professional history of your own projects. It's not just another tool; it's a fundamental part of every developer's toolkit.
Setting Up Your Git Environment
Before you can track a single line of code, you need to get Git up and running on your machine. Think of this as the one-time setup that lays the foundation for every project you'll ever work on with version control. The good news? Installing Git is a breeze, no matter what operating system you're using.
For pretty much everyone, the quickest way to get started is by heading over to the official Git website and grabbing the right installer for your system. This single package has everything you need, including the essential command-line tools.
Installing Git on Your Machine
The installation process is slightly different depending on your OS, but each one is designed to be painless.
On Windows: Download the Git for Windows installer. This gives you the full command-line experience and plays nicely with both the Windows Command Prompt and PowerShell. When you run through the setup, it's perfectly safe to accept most of the default options—they’re sensible choices for anyone just starting out.
On macOS: The easiest method is to install the Xcode Command Line Tools. Just open your Terminal and type
git --version. If Git isn't already there, your system will pop up a prompt to install the tools, which includes Git. Simple as that.On Linux: You can usually install Git right from your distribution's package manager. For Debian/Ubuntu, you’d use
sudo apt-get install git. If you're on Fedora, you'd runsudo dnf install git.
Once the installation is done, pop open your terminal or command prompt and run git --version again. If you see a version number printed out, like git version 2.45.1, you're all set. Git is successfully installed and ready for action.
Your First-Time Git Configuration
With Git installed, there are a couple of crucial configuration settings you absolutely must set up. These commands are how you tell Git who you are, attaching your identity to every single change you make. This isn't just a formality; it's fundamental to how collaborators know who authored what.
First, you’ll need to set your name and email address. Git embeds this info into every commit you create.
git config --global user.name "Your Name" git config --global user.email "youremail@example.com"
That --global flag is important—it tells Git to use these settings for every single project on your computer. You only have to do this once.
Pro Tip: Make sure the email you use here is the same one you plan on using for services like GitHub. This little bit of consistency is key to linking your local commits to your online profile, making sure your contribution history is tracked correctly.
Another highly recommended tweak is setting your default code editor. This is the editor that Git will automatically open whenever it needs you to type a message, like for a commit.
For instance, if you want to set Visual Studio Code as your default, you'd use this command:
git config --global core.editor "code --wait"
This small adjustment makes a huge difference in your workflow. Instead of being thrown into a potentially unfamiliar terminal editor like Vim, Git will open an environment where you're already comfortable and efficient. Taking a few moments for this initial setup really pays off, ensuring a much smoother experience as you get started with Git.
Making Your First Commit: A Practical Walkthrough

Alright, you've got everything configured. Now it's time to put theory into practice and start tracking a real project. This is where you'll see how just a few simple commands form the backbone of your entire version control workflow.
Let's say you're starting a new personal portfolio website from scratch.
First thing's first, pop open your terminal and navigate to your project's folder. To tell Git to start watching this directory, you'll run the initialization command.
git init
Once you hit enter, Git creates a new, hidden subdirectory called .git. This little folder is the brain of your local repository—it's where Git tucks away all the metadata and history for your project. From this moment on, Git is officially keeping an eye on things here.
Understanding the Staging Area
One of the most powerful—and initially confusing—concepts in Git is the staging area, which you'll also hear called the "index." Think of it as a drafting table for your next commit. Instead of every single file save being logged directly, you deliberately choose which changes to add to the staging area first. This two-step dance gives you incredible control over what goes into each snapshot of your project.
This is incredibly useful. You might make several edits across a dozen files but only want to group related changes into a single, logical commit. For instance, you could fix a typo in your README.md and simultaneously tweak a CSS style, but you can choose to commit only the README.md fix first.
Let's make our first file, an index.html.
touch index.html
Now, if you run git status, Git will report back that it sees a new, "untracked" file. It knows index.html exists, but it's not part of your version history just yet.
To get it ready for a commit, you need to add it to that staging area.
git add index.html
The git add command is you telling Git, "Hey, I want to include the current state of this file in my next official save." You can add single files, multiple files, or even entire directories. If you run git status again, you'll see index.html is now staged and ready to be committed.
Key Takeaway: The staging area is your final review point before creating a permanent snapshot. It forces a deliberate pause, encouraging you to craft well-organized commits that tell a clear story about your project’s evolution.
Creating Your First Snapshot with a Commit
Once you have your changes lined up in the staging area, you're ready to lock them in with a commit. The git commit command takes everything you've staged and saves it permanently to your project's history. Each commit becomes a unique checkpoint you can always return to.
But a commit is nothing without a message. This message is a short description of the changes you've made, and learning to write good ones is a skill that separates the pros from the amateurs.
To create the commit, run this:
git commit -m "Initial commit: Create index.html"
The -m flag lets you write a short, descriptive message right from the command line, explaining what this commit accomplishes. And just like that, your first commit is saved! It has a unique ID (a long string of characters called a hash) and is officially the first point in your project's history.
This simple loop—modify, add, commit—is the fundamental rhythm you'll follow as you get started with Git. It’s a workflow that ensures every change is captured intentionally and with purpose. This entire workflow, by the way, gained massive traction thanks to platforms that host repositories. The success of Git is inseparable from the rise of GitHub, which launched in 2008 and created a social coding platform that massively boosted Git adoption. You can find more cool tidbits about Git's history at welcometothejungle.com.
Taking the time to write meaningful commit messages pays off tenfold, especially when you're working on a team or looking back at your own code six months from now.
- Be concise and clear: The subject line (what you put after
-m) should summarize the change in 50 characters or less. - Use the imperative mood: Write as if you're giving a command. Think "Add contact form" instead of "Added a contact form." It's a convention that keeps things consistent.
- Explain the 'why': For more complex changes, you can leave off the
-mflag. This will open your default text editor, giving you space to write a more detailed message body explaining why a change was necessary, not just what was changed.
Working with Branches and Merging Your Changes
Think of your project like a novel with a main plotline. Branching in Git is like writing a side chapter to explore a new character arc without disrupting the core narrative. This is the feature that elevates Git from a simple file history tool into a powerhouse for safe experimentation and collaboration. Honestly, it's fundamental to how you should get started with Git.
When you're ready to build a new feature—let's say an account settings page for your app—you definitely don't want to build it directly on your stable, production-ready code. That would be like performing open-heart surgery in the middle of a marathon.
Instead, you create a new branch. This branch is a perfect snapshot of your project at that exact moment, giving you a completely isolated sandbox to work in. Your main branch, usually called main or master, stays pristine and functional. Meanwhile, you can go wild on your feature branch, knowing nothing you do will break the main project until you decide it's ready.
Creating and Switching Between Branches
Creating a branch is a surprisingly simple and lightweight operation. Let's say we want to create a branch called feature/account-settings. Pop open your terminal and run this command:
git branch feature/account-settings
This creates the new branch, but here's a key detail: it doesn't automatically move you to it. You're still on your original branch. To actually start working in your new sandbox, you need to "check out" that branch.
git checkout feature/account-settings
Of course, developers love shortcuts. There's a command that combines both of these steps, and you'll probably find yourself using it 99% of the time:
git checkout -b feature/account-settings
The -b flag is your friend here; it tells Git to create the new branch and immediately switch over to it. Now, any commits you make are recorded on this new timeline, completely separate from main. This workflow is a lifesaver for teams where multiple people are tackling different features at once. For more complex projects, you'll find different branching models work better; we actually have a deep dive on monorepo branching strategies for teams in our guide.
This diagram gives you a great visual of the basic Git workflow, showing how changes move from your local machine, to a staging area, and finally into your repository's history on a specific branch.

Each of these steps is a deliberate action, giving you total control over what gets saved into your project's permanent record.
Merging Your Work Back
Okay, so you've built the perfect account settings page on its own branch. You've tested it, and it's ready for the spotlight. It's time to bring that work back into the main project. This process is called merging.
First things first, you need to switch back to the branch you want to merge into. In our case, that's the main branch.
git checkout main
With that done, you run the merge command, telling Git which branch you want to pull the changes from.
git merge feature/account-settings
Git will analyze the history of both branches and intelligently weave the changes together. It creates a new "merge commit" on the main branch that incorporates all the work you did on your feature branch.
Pro Tip: Before you merge, it's always a good idea to make sure your
mainbranch is up-to-date with any changes from the remote repository (like GitHub). A quickgit pullonmainbefore merging can save you from a world of headaches and unexpected conflicts.
Once the merge is done, your new feature is officially part of the main project. The feature/account-settings branch has served its purpose, and to keep your repository clean and easy to navigate, you can safely delete it.
git branch -d feature/account-settings
This cycle—create a branch, checkout, commit, merge, and delete—is the bread and butter workflow for millions of developers. It keeps projects organized, stops teammates from stepping on each other's toes, and makes managing new features a breeze. Mastering this process is a huge leap forward as you get started with Git.
Connecting Your Local Project to GitHub

Managing your project locally is a huge step, but the real magic happens when you connect it to a remote hosting service. This is where your code gets a secure offsite backup and becomes a gateway for collaboration. The undisputed leader in this space is GitHub, home to millions of open-source and private projects.
Think of GitHub as a social network for your code. It provides a web-based home for your Git repositories, making it incredibly easy to share your work, track issues, and collaborate with developers from around the globe. It's an essential tool if you want to get started with Git professionally.
Setting Up Your First Remote Repository
First things first, you'll need a new, empty repository on GitHub. Once you're signed in, hit the "New" button on your dashboard. Give your repository a name—it's a good habit to use the same name as your local project folder just to keep things clear—and decide if it should be public or private. For now, you can leave the other options unchecked since you already have a project ready to go.
GitHub will then show you a page with a few handy commands. The piece of information you're looking for is the URL for your new repository. It will look something like this:
https://github.com/your-username/your-project-name.git
This URL is the exact address Git will use to find your repository on the web.
Now, jump back to your terminal, make sure you're in your local project directory, and run the following command. This one-liner tells your local Git repo about the remote one on GitHub and gives it the nickname origin.
git remote add origin https://github.com/your-username/your-project-name.git
Key Insight: Using
originas the nickname for your primary remote repository is a near-universal convention. You could technically name it anything, but sticking withoriginmakes your project instantly familiar to any other developer who might work on it down the line.
Pushing Your Code to GitHub
With the connection established, you're ready to send your local commit history up to GitHub. This process is called pushing. The very first time you do this, you need to be explicit and tell Git which local branch to push and where it should go on the remote server.
git push -u origin main
Let's break that down:
git push: The command to send your commits.origin: The remote repository you're pushing to (the nickname you set).main: The local branch you're sending up.-u: This is a one-time flag that setsorigin mainas the default "upstream" for your current local branch.
After this initial push, any future updates are much simpler. You can just run git push.
And that's it! Your code is now live on GitHub. This simple workflow is the foundation for creating pull requests, which are central to team collaboration. To make this process even smoother, you can explore using high-quality pull request templates to improve your review process and keep communication crystal clear.
Common Questions When You Get Started with Git
When you're first dipping your toes into Git, a few questions pop up almost immediately. Let's walk through some of the most common ones to help you get your bearings and start working with confidence.
What Is the Difference Between Git and GitHub
It's easy to get these two mixed up. The simplest way I've found to explain it is this: Git is the tool, and GitHub is the workshop.
You install Git right on your machine. It’s the actual version control software that tracks your changes, lets you create branches, and manages your project’s history locally.
GitHub, on the other hand, is a web-based service where you can store your Git repositories. Think of it as a central hub for your projects, making it easy to back up your code and, more importantly, collaborate with others.
How Can I Undo My Last Commit
We've all been there—you commit something and immediately spot a mistake. Don't worry.
If you just made the commit and haven't pushed it anywhere, the easiest fix is the command git reset --soft HEAD~1. This command basically rewinds the last commit but keeps all your changes staged and ready to go. You can then tweak your files or just write a better commit message before trying again.
Key Takeaway: Git is designed to be a safety net. Nearly every action is reversible, so don’t be afraid to experiment. Learning how to fix mistakes is a core part of mastering version control.
What Does Cloning a Repository Mean
"Cloning" a repository is just a fancy way of saying you're making a complete, local copy of a project from a remote source like GitHub.
When you clone a project, you're not just getting the latest files—you're getting the entire project history, every single branch, and every commit ever made. This sets you up to start working on the project right away on your own machine.
Once you’ve made your changes locally, you'll push them back up and likely open a pull request. That process comes with its own set of best practices, which you can learn more about in our guide to pull request best practices.
With PullNotifier, you can keep your entire team in sync with real-time, consolidated pull request updates directly in Slack. Stop drowning in email notifications and start merging faster. Try it for free at https://pullnotifier.com.