No history yet

Introduction to Git and GitHub

Keeping Track of Changes

Have you ever worked on a big project, like a research paper or a piece of code, and ended up with a folder full of files named final_draft.doc, final_draft_v2.doc, and REALLY_final_this_time.doc? It gets confusing fast. If you want to go back to an earlier idea or see what you changed last Tuesday, it can feel like a treasure hunt without a map.

This is where version control systems (VCS) come in. A VCS is like a time machine for your project. It automatically records every change you make to a file or set of files over time. This means you can recall specific versions later, compare changes, and see who contributed what and when. It provides a single source of truth, eliminating the chaos of managing multiple file versions manually.

Essentially, a version control system provides a complete history of your project, allowing you to move backward and forward through changes with ease.

Git and GitHub

Two names you'll hear constantly in the world of version control are Git and GitHub. They are related, but they are not the same thing. It's a common point of confusion for beginners.

Git is the version control software itself. It's a tool you install and run on your local computer. Git is responsible for tracking the changes in your files, a process often called 'local version control.' It’s a distributed version control system, which means that every developer working on a project has a full copy of the project's history on their own machine. This allows people to work independently and then merge their changes together later.

GitHub is a web-based hosting service for Git repositories. Think of it as cloud storage for your projects, but with powerful tools for collaboration built on top. It's a platform where you can upload your Git-managed projects, share them with others, and work together. While Git handles the version tracking, GitHub provides a central place to store your project and manage teamwork.

This diagram shows the basic workflow. You work on your files, use Git on your computer to track and save snapshots of your changes, and then use GitHub to store those changes online and collaborate with others.

Getting Git Set Up

Before you can start using Git, you need to install it on your computer. The process is straightforward and varies slightly depending on your operating system.

  • Windows: The easiest way is to download the official installer from the Git website. Run the installer and accept the default settings. This will give you access to Git commands through a special terminal called Git Bash.
  • macOS: If you have Homebrew installed, you can simply open your terminal and run brew install git. Alternatively, installing Xcode Command Line Tools will also install Git.
  • Linux: You can typically install Git using your distribution's package manager. For Debian-based systems like Ubuntu, you would use apt-get.
# For macOS with Homebrew
brew install git

# For Debian/Ubuntu
sudo apt-get update
sudo apt-get install git

After installing Git, there's one last step: configuring it with your information. Every time you save a snapshot of your work (a 'commit'), Git includes your name and email. This is crucial for tracking who made which changes, especially when working on a team.

You only need to do this once on any new machine. Open your terminal or Git Bash and run the following commands, replacing the placeholder text with your actual name and email address.

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

The --global flag tells Git to use this information for every project you work on. With Git installed and configured, you're ready to start tracking your projects.

Quiz Questions 1/5

What is the primary purpose of a Version Control System (VCS)?

Quiz Questions 2/5

Which of the following statements best describes the relationship between Git and GitHub?

Now that you understand the basics of what version control, Git, and GitHub are, you're ready to start putting them to use.