Git Good!
Learn all about Git
October 13, 2025
Git Version Control
Git is a version control system (VCS), which is a fancy way of saying it’s a tool that tracks changes to your code. Think of it like a super-powered “undo” button for your entire project, combined with the ability to see who changed what, and when. It’s the industry standard for collaborating on software.
Core Concepts
Understanding these ideas is key to using Git effectively.
- Repository (Repo): This is your project folder. A Git repo contains all of your project files and the entire history of changes.
- Commit: A snapshot of your repository at a specific point in time. Each commit has a unique ID and a message describing the changes.
- Branch: An independent line of development. You can create a new branch to work on a new feature without affecting the main codebase (usually called the
mainormasterbranch). - Merge: The process of combining the changes from one branch into another.
- Staging Area: An intermediate step before committing. You add files to the staging area to tell Git exactly which changes you want to include in the next commit.
- Remote: A version of your repository hosted on a server, like GitHub or GitLab. It’s the central place where you and your team can share code.
- Push & Pull: Pushing sends your committed changes to a remote repository. Pulling fetches changes from a remote repository and merges them into your local copy.
Common Git Commands
You’ll be using these commands constantly in your terminal.
git init: Initializes a new Git repository in the current directory.git clone <url>: Creates a local copy of a remote repository.git status: Shows the current state of your repository (which files are modified, staged, etc.).git add <file>: Adds a file’s changes to the staging area. Usegit add .to stage all changes.git commit -m "Your message": Saves the staged changes as a new commit with a descriptive message.git log: Displays the commit history.git branch <name>: Creates a new branch.git checkout <branch>: Switches to a different branch.git merge <branch>: Merges the specified branch into your current branch.git pull: Fetches and merges changes from the remote repository.git push: Pushes your committed changes to the remote repository.
Setup Guide
-
Download and Install Git
- Go to https://git-scm.com/downloads
- Download the installer for your operating system (Windows, macOS, or Linux).
- Run the installer, accepting the default options is usually fine.
-
Configure Your Identity
- Open a terminal (or Git Bash on Windows).
- Tell Git who you are. This information is attached to every commit you make.
git config --global user.name "Your Name" git config --global user.email "youremail@example.com" -
Check Your Configuration
- You can verify your settings with this command:
git config --list
Challenges
-
Install Git and configure your username and email. (50 pts)
-
Create your first local repository. (50 pts)
- Create a new folder on your computer.
- Initialize a Git repository inside it (
git init). - Add a new file (e.g.,
README.md) with some text. - Stage the file (
git add). - Make your first commit (
git commit).
-
Push your repository to GitHub. (30 pts)
- Create a new, empty repository on GitHub.
- Connect your local repository to the remote one on GitHub.
- Push your local commit to GitHub.
Tips for Challenge 3:
Linking a Local Repo to GitHub
-
Create a New Repository on GitHub:
- Log in to GitHub and click the ”+” icon in the top-right, then select “New repository.”
- Give it a name, but do not initialize it with a README, .gitignore, or license file (since you already have a local repo).
- Click “Create repository.”
-
Get the Remote URL:
- On the next page, GitHub will show you the repository’s URL. Copy the HTTPS or SSH URL. It will look something like
https://github.com/your-username/your-repo-name.git.
- On the next page, GitHub will show you the repository’s URL. Copy the HTTPS or SSH URL. It will look something like
-
Link and Push from Your Terminal:
- In your terminal, navigate to your local project folder.
- Run the following commands, replacing the URL with the one you copied.
# Link your local repo to the remote GitHub repo git remote add origin https://github.com/your-username/your-repo-name.git # Rename your default branch to 'main' (a common standard) git branch -M main # Push your 'main' branch to the remote repo named 'origin' # The -u flag sets the upstream so you can use 'git push' by itself in the future git push -u origin main -
Verify:
- Refresh your GitHub repository page. You should now see your
README.mdfile and your first commit!
- Refresh your GitHub repository page. You should now see your