Github logo

Introduction to Git and GitHub

Alright, I know you’ve heard of GitHub and probably but don’t understand exactly what it is. Or maybe you DO understand it but don’t know how to really get started. Either way, this post is here to help you understand the concept a bit better.

So let’s say you are working on something, a website, notes, code, a project or just homework.

You change one small thing, and all of sudden your computer starts crashing. You’re panicking because you cannot remember if you saved the changes. You’re hoping that once close all the extra tabs, you reboot or restart there is an auto save waiting for you to pick up where you left off…

That autosave, is what we call in this scenario “Git”.

Git is a powerful version control system that helps track changes in your work over time, allowing multiple people to collaborate seamlessly on the same project.

It is a detailed history book for your work, recording every modification, addition, or deletion.

So how does it work?

It works by watching your files and tracks changes to your code so you don’t mess things up permanently.

Git allows you to:

  • Roll back to an earlier version when you make mistakes (and you will make mistakes)
  • Save different versions of your work (snapshots).
  • Work on projects with others without stepping on each other’s toes.

Each saved moment is called a commit. A commit is just a snapshot with a short note explaining what you did.

So in theory, it’s a timeline of your work.

You can move forward,

go backwards,

or do a comparison of two points at the same time and see exactly what changed. And it all is captured right on your computer. That’s exactly where Git lives. You don’t really need internet to use it.

But GitHub Is Different

GitHub is not Git.

GitHub is a home for your Git projects but on the internet.

It gives you:

  • A backup if your computer dies
  • Access to your work from anywhere
  • A way to share your work with others
  • A public record of what you’ve built (digital portfolio)

Put simple, Git is your brain remembering things, GitHub is long-term memory stored and made available whenever you need it.

Key Difference Between the two:

The most important aspect to consider is that Git is a local software, while GitHub is an online service. However, the primary reason why most people prefer to use both is the real-life collaboration that can be achieved from anywhere. You can manage and share resources, and track changes when necessary, which is all essential in the digital realm.

  • Git does the tracking of changes
  • GitHub shares those online
  • Everything else is build on that
  • You can use Git without Github, but you can’t use GitHub without Git.

Getting Set-Up

To get started it is quite simple.

  1. Configure Your account
Setting Up an Account

2. Verify your email and then set up 2FA (two-factor authentication)

To set this, go back to the main home page of your newly created account and click on the profile icon

  • Scroll down and click on settings.
  • Under the section Access, scroll down to locate and click on Password & Authentication.
  • On the right panel side, Locate Two-factor authentication, click Enable, and then follow the prompt to complete the full set up.

Now let’s shift and configure Git

There are two ways to do this. You can either do it separately or you can just GitHub desktop where it will automatically have git within it.

Option 1:

Install Git on your computer ( If not pre-installed).

  • Follow the installation steps (it’s a straightforward, promise).
  • Go to git-scm.com and download it.

Since I have Mac, I am going to download Xcode, from the appstore on Mac.

  • Once it has been downloaded, it is time to config it:
    • Open your terminal (or command line) and type the following:
git config --global user. name "Your Name" git config --global user.email "your.email@example.com"

This tells Git who you are. You are introducing yourself to the system.


Option Two:

For a more visual interface – Download the Git-Hub desktop. (easiest method )

  • Search for GitHub Desktop
  • Download for appropriate systems- I did it for Mac.
  • Once downloaded, open the GitHub desktop zip file.
  • Unzip, Install, Authenticate and you’re good to go.

Common Terms You Should Know

With Git, you can save and organize your changes more efficiently in one place.

  • Working Directory: This is your workspace where you make changes.
  • Staging Area: A place where your changes are prepared before being committed.
  • Local Repository: A saved history of your project stored on your computer.
  • Remote Repository: Your project’s backup on GitHub, accessible online.
  • Branches: a copy of your project where you can experiment or make changes without affecting the original.
  • Pull Request: A request to merge changes from one branch into another, commonly used in team projects.
  • Merging: Combining changes from different branches into one.

Creating a Repository (Repo):

There are two ways to set up your first repository and that is by making it either public or private.

  • Public: Share your work with the world.
  • Private: Keep your work limited to specific people.

Basic Commands to Get You Started

Let’s start practicing Git commands.

Open your terminal and follow along:

  1. Create a Folder
mkdir git-practice 
cd git-practice

This creates and navigates into a new folder where your Git project will live.

2. Open Your Code Editor:

code.

This creates a new file called hello.md in your folder.

3. Create a file:

touch hello.md

4. Check Git Status (Pre-initialization):

git status

You’ll see an error because Git hasn’t been initialized yet.

6. Check Git Status Again:

git status

You’ll See the file hello.md in red, meaning it’s untracked.

7. Add Files to Staging:

git add

This stages all changes in your working directory. if you run Git status again, hello.md will appear in green, meaning it’s staged.

8. Commit Your changes:

git commit -m "initial commit"

This saves your changes with a message explaining what you did. Messages like “initial commit” help keep track of changes as your project grows.


What’s Next?

With these basic commands, you’ve taken your first steps into the world of both Git and GitHub.

From here, you can:

  • Experiment with creating branches and merging changes.
  • Push your project to Github (remote repository) for collaboration.
  • Build your confidence with Git as you work on small coding projects.

Again, Git can seem overwhelming at first, but with practice, it becomes second nature. If you’re following along, congratulations on starting your journey!

Keep experimenting and learning, you’ve got this! – AJ

Post Author

AJ

I created this blog for two reasons: 
To keep myself accountable as I learn and grow in this field. To provide beginner-friendly resources for others who are just starting or want to take their skills to the next level. 


Popular Articles

Top Categories

Top News

Social

Introduction to Git and GitHub - AJ Security Ledger