Git & Github - First Project

What is Git & GitHub?

Git is a version control system.. it lets you track changes in your code over time.
GitHub is an online platform where you can store Git repositories, collaborate, and share your projects.

Think of it as:
“Git saves your project’s history, GitHub makes it easy to share that history with others.”

Git & Github - Git + Github png.png


A typical Git workflow looks like..

  1. Initialize a Git repository in your project (git init).
  2. Add files you want Git to track (git add).
  3. Commit changes with a message (git commit).
  4. Push your commits to GitHub (git push).

Git & Github - Workflow.png

This ensures your code history is saved locally and synced to GitHub.


Why it’s useful

With Git & GitHub you can:

  • Keep a history of changes (never lose work).
  • Collaborate with teammates (branches, pull requests).
  • Roll back to an earlier version if something breaks.
  • Work safely on new features without touching stable code.

Git & Github - Benefits diagram.png


Step by Step - Guide

Prerequisites

  • Install Git here (git --version <-- typing this in the Terminal will show it as installed)
    • If this doesn't work, make sure you restart the computer!
  • A GitHub account
  • A project folder ready
  • Github Tokens setup
  • Basic Terminal knowledge

Git & Github - First Project Workflow.png


First: Create a Repository on GitHub

Before we publish anything, we need a repository (repo) on GitHub.. this will be the “home” for your project.

Step 0

Create Repository

  1. Go to GitHub
  2. In the top-right corner, click the +, Create New and choose New repository
    Git & Github - Repository Creation.png
  3. Name your repo (e.g. my-first-repo)
  4. Choose visibility:
    • Public (anyone can see it)
    • Private (only you and collaborators)
  5. Important: Leave “Add a README” unchecked (we want an empty repo to push to)
  6. Click Create repository

Preparing a Local Project

Now let’s make something simple that we’ll upload to GitHub.

Step 1

Create Project Folder
Create an empty folder for the project and add a file to track.

Mac / Linux (Terminal):

mkdir my-first-repo
cd my-first-repo
echo "This is my backup." > my-backup.txt
ls

Windows (PowerShell):

mkdir my-first-repo
cd my-first-repo
echo "This is my backup." > my-backup.txt
dir

You should now see a file called my-backup.txt in the folder.


Publishing Our Local Project to GitHub

Before we begin..

Navigate to your project within the terminal
Always make sure you’re in your project’s root directory before running Git commands.
If you’re in the wrong place, you might accidentally publish sensitive files.

Check your current location with:

pwd

If you accidentally initialized a Git repository and want to remove it, see the bottom section for more information.


Step 2

Initialize a Git Repository

Inside your project folder:

git init

This creates a hidden .git folder where Git tracks your project’s history.

Verify
type ls -a to verify the existence of the .git folder





Removing Unwanted Initialized Git Repositories

Accidental git init

If you accidentally initialized a Git repository and want to remove it,
delete the hidden .git folder:

rm -rf .git

This completely removes Git tracking from the project.
This will remove all local commits therefore it is recommended to perform a project backup!



Now what?

Success

YOU DID IT!
Practice creating a repo, adding files, committing, and pushing to GitHub.
Next step: learn branches and pull requests for teamwork!


Git & GitHub - Documentation


Finished

Back to Overview: Developer Fundamentals