No history yet

Git and GitHub Basics

Saving Your Work, The Smart Way

Imagine you're writing a long essay. You might save different versions as you go: essay_draft_1.doc, essay_final.doc, essay_REALLY_final.doc. This gets messy fast. If you want to go back to an idea from an early draft, you have to dig through old files. If you're working with a partner, you're emailing files back and forth, trying to merge your changes without overwriting each other's work.

Version control systems solve this problem. They are tools that help you track and manage changes to your files over time. Instead of juggling multiple files, you have one project folder where the system records every change you make.

Lesson image

Git is the most widely used version control system today. It lets you take "snapshots" of your project at any point. These snapshots, called commits, create a detailed history of your project. You can easily revisit any previous version, see who changed what, and work on new ideas without messing up the main project.

Core Git Concepts

There are three key ideas you need to understand to use Git effectively.

Repository

noun

A project's folder containing all of its files and the entire history of changes. Often shortened to "repo."

Next up is a commit. A commit is a snapshot of your repository at a specific point in time. When you've made some changes—like adding a new feature or fixing a bug—you commit them with a message describing what you did. This creates a checkpoint in your project's history that you can always return to.

Finally, we have branches. A branch is like a parallel timeline for your project. The main branch (usually called main or master) holds the official, stable version of your code. When you want to work on something new, you create a new branch. This gives you an isolated space to experiment. Once your work is complete and tested, you can merge your branch back into the main one.

So, What's GitHub?

If Git is the tool, GitHub is the place where you store your Git repositories and collaborate with others. It's a web-based hosting service for version control using Git. Think of it like a social network for developers.

You can host your repositories for free, explore millions of open-source projects, and contribute to them. GitHub adds a layer of collaborative features on top of Git.

GitHub has its own set of key concepts. A repository on GitHub is the same as a Git repo, but it lives on GitHub's servers, making it accessible from anywhere. Two of the most important collaboration features are issues and pull requests.

Issues are a way to track tasks, enhancements, and bugs for your projects. Anyone can create an issue to report a problem or suggest a new idea. It's like a dedicated to-do list and discussion forum for the project.

A pull request is how you propose changes. After you've worked on a new feature on a separate branch, you open a pull request. This lets others review your changes, discuss them, and suggest modifications before you merge them into the main branch. It's the heart of collaborative coding on GitHub.

Git vs. GitHub

The distinction is simple but important.

  • Git is the version control software you install and run on your local computer. It's the command-line tool that tracks changes.
  • GitHub is the website where you host your Git repositories online. It provides a graphical interface and collaborative tools.

You can use Git perfectly fine without ever using GitHub. However, you can't use GitHub without using Git. The two are designed to work together to make it easier for teams to build software.

Analogy: Git is like Microsoft Word, the program on your computer for writing. GitHub is like Google Docs, the online platform where you can store, share, and edit your documents with others.

Let's review these key terms.

Ready to check your understanding?

Quiz Questions 1/6

What is the primary problem that version control systems like Git are designed to solve?

Quiz Questions 2/6

In Git, a 'commit' is best described as:

Understanding these fundamentals is the first step to managing your code effectively and collaborating with other developers.