Voltar para o BlogTutoriais

Practical Guide: Getting Started with Git and GitHub

A hands-on tutorial to install Git, set up your GitHub account, and make your first commit. From zero to a repository in minutes.

M
Marina Borges
Founder & CEO
5 de março de 20268 min de leitura

Practical Guide: Getting Started with Git and GitHub

If you work -- or plan to work -- with Salesforce, especially on the development side, you're going to run into Git and GitHub sooner or later. Actually, probably sooner. It's one of those skills nobody teaches you in school, but every tech lead expects you to know on day one.

The good news: Git isn't as complicated as it looks. In this guide, I'll take you from zero to your first repository on GitHub, step by step. No mystery, no unnecessary jargon.

What is Git (and why you need it)

Git is a version control system. In practice, it tracks every change you make to your files and lets you go back to any previous version. Think of it as a smart, infinite "Ctrl+Z" for your code.

GitHub is an online platform that hosts Git repositories. It's where teams collaborate, review code, and keep projects organized. If Git is the engine, GitHub is the garage in the cloud.

Every serious company working with Salesforce uses Git. If you want to stand out in the job market, mastering these tools isn't optional -- it's a prerequisite.

Installing Git on your computer

The process is simple and takes less than 5 minutes, regardless of your operating system.

Windows:

Download the installer from git-scm.com. During installation, accept the default options. It includes Git Bash, a dedicated terminal that emulates Linux commands on Windows -- that's what we'll use in this tutorial.

macOS:

Open Terminal (search "Terminal" in Spotlight with Cmd+Space) and type:

git --version

If Git isn't installed, the system will offer to install it automatically. You can also install it via Homebrew:

brew install git

Linux (Ubuntu/Debian):

sudo apt update && sudo apt install git

For Fedora: sudo dnf install git.

Verifying the installation:

After installing, open the terminal and confirm:

git --version

If you see something like git version 2.43.0 (any version 2+), you're all set.

Tip: if the git command isn't recognized on Windows, restart the terminal or your computer. The installation may need a fresh terminal session.

Initial setup: your identity

Before using Git, you need to configure your name and email. This information appears in every commit you make -- it's your digital signature.

git config --global user.name "Your Name"
git config --global user.email "your@email.com"

To confirm it worked:

git config user.name
git config user.email

The --global flag means these settings apply to all repositories on your computer. You only need to do this once.

Important: use the same email you'll register on GitHub. This ensures your commits are linked to your profile. If the emails don't match, your contributions will show up as from an unknown user.

Optional but recommended -- set VS Code as your default editor:

git config --global core.editor "code --wait"

Getting to know the terminal: basic commands

A lot of people are intimidated by the terminal -- that black screen with text. But it's simpler than it looks. To work with Git, you only need 5 navigation commands:

CommandWhat it doesExample
pwdShows which folder you're inpwd/Users/you/projects
lsLists files in the current folderlsfolder1 folder2 file.txt
cd folderEnters a foldercd projects → enters the folder
cd ..Goes up one foldercd .. → goes up one level
mkdir nameCreates a new foldermkdir my-project → creates the folder

Tip: the Tab key autocompletes folder and file names in the terminal. Start typing and press Tab. This prevents typos and speeds everything up.

On Windows, if you're using Git Bash (recommended), these same commands work normally. Outside of Git Bash, the equivalents are different (dir instead of ls, for example), so use Git Bash to follow along with this tutorial.

Creating your first repository

Now for the fun part. Let's create a Git repository from scratch, right in the terminal.

Step 1 -- Create a folder for the project and navigate into it:

mkdir my-first-repo
cd my-first-repo

Step 2 -- Initialize the Git repository:

git init

This command creates a hidden subfolder called .git inside your project. That's where Git stores the entire history. From this point on, this folder is a Git repository -- every change can be tracked.

Step 3 -- Create a file:

echo "# My First Project" > README.md

Step 4 -- Check the repository status:

git status

You'll see that README.md appears as "untracked" (in red). This means Git knows the file exists but isn't tracking it yet.

Your first commit

This is where the magic happens. The basic Git workflow follows three steps: editgit add (stage) → git commit (save to history).

Step 5 -- Add the file to staging:

git add README.md

The staging area is where you select which changes you want to include in the next commit. Not everything you changed needs to go into the same commit -- and that's one of Git's great advantages.

Step 6 -- Make the commit:

git commit -m "First commit: add README"

Done. You just saved the first version of your project to Git's history. The -m flag lets you write the commit message directly in the command line.

Commit message best practices: use imperative verbs and be descriptive. "Add email validation" is much better than "miscellaneous changes". If someone reads only the message, they should understand what was done without looking at the code.

To view your commit history:

git log --oneline

Tip: to exit the git log screen, press the q key. A lot of beginners get stuck on this screen.

Connecting to GitHub

Up to now, everything is on your computer (local). To put your project on GitHub, follow these steps:

1. Create a GitHub account at github.com (if you don't have one yet).

2. Create a new repository by clicking "New repository". Give it the same name as your folder (my-first-repo). Don't check any initialization options (no README, no .gitignore).

3. Connect your local repository to GitHub:

git remote add origin https://github.com/your-username/my-first-repo.git

4. Push your code to GitHub:

git push -u origin main

The -u origin main sets up tracking, meaning it tells Git that the local main branch corresponds to the main branch on GitHub. You only need to use -u on the first push. After that, just git push.

Refresh the GitHub page and you'll see your file there. Congratulations -- your code is in the cloud.

The daily workflow: add, commit, push

Once the repository is set up, your daily routine with Git boils down to:

# 1. Make your changes to files

# 2. See what changed
git status

# 3. Add changes to staging
git add changed-file.txt

# 4. Make the commit
git commit -m "Describe what was done"

# 5. Push to GitHub
git push

And when working on a team, always start your day with:

git pull

This downloads the changes other team members pushed to GitHub. Always git pull before git push -- if someone pushed commits you don't have, the push will be rejected.

Golden rule: starting your day? git pull. Wrapping up? git push. Small, frequent commits throughout the day. Simple as that.

FAQ

What's the difference between Git and GitHub?

Git is the version control tool that runs on your computer. GitHub is an online platform that hosts Git repositories and offers collaboration features (Pull Requests, Issues, etc.). You can use Git without GitHub, but not GitHub without Git.

Do I need to use the terminal to use Git?

Technically, there are graphical interfaces (like GitHub Desktop and the VS Code panel). But learning the basic commands in the terminal gives you more control and is what most professional teams use. The 5 navigation commands I showed here are all you need to get started.

What is a commit, in practice?

A commit is like taking a "snapshot" of the current state of your files. It records exactly what changed, when, and who made the change. You can go back to any previous commit if needed. Think of it as a save point in a video game.

I messed up a commit. How do I undo it?

If you want to undo the last commit but keep the changes in your files, use:

git reset --soft HEAD~1

This removes the commit from history but keeps your files intact. You can fix things and commit again.


If you want to go beyond this tutorial and truly master Git and GitHub -- with hands-on exercises, quizzes, and guided projects -- check out the Git & GitHub Essentials course at Rangers League Academy, available at /en/academy. There you'll learn everything from the fundamentals to advanced workflows like branching, merging, conflict resolution, and Pull Requests. All at the right pace for beginners.

#git#github#git-tutorial#first-commit#version-control
Compartilhar
Marina Borges

Marina Borges

Fundadora & CEO

Fundadora da Rangers League e Salesforce Professional apaixonada por tornar o ecossistema Salesforce mais acessível para profissionais de toda a América Latina. Acredita que educação de qualidade e comunidade são os maiores aceleradores de carreira.