Menu

THE ONE TRUE METHOD

GIT GUD
AT GITHUB

Stop dragging and dropping files like a peasant. Learn the command line. It's fast, it's raw, and it works.

Git Setup

A

Install Git (Windows)

Download and run the Git for Windows installer. Defaults are fine for beginners.

Download Git for Windows
$
https://git-scm.com/download/win

Run the downloaded .exe and follow the installer. After installation, verify:

Verify Git
$
git --version
Optional: GitHub CLI (Windows)

You can install the GitHub CLI to make authentication easier:

Install gh (winget)
$
winget install --id GitHub.cli
B

Install Git (macOS)

Recommended: install via Homebrew. Alternatively, use Xcode Command Line Tools.

Install Homebrew (if needed)
$
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Install Git (Homebrew)
$
brew install git
Or: Xcode Command Line Tools
$
xcode-select --install
Verify Git
$
git --version
Optional: GitHub CLI (macOS)
Install gh (Homebrew)
$
brew install gh
C

Configure Identity

Set your name and email so commits are attributed to you.

Check username
$
git config --get user.name
Set name
$
git config --global user.name "Your Name"
Set email
$
git config --global user.email "your.email@example.com"

Verify your configuration:

Show config
$
git config --list
D

Authenticate with GitHub

Use the GitHub CLI to authenticate (recommended). It guides you through a web-based login and makes HTTPS pushes painless.

Start GitHub CLI login
$
gh auth login
  1. Select GitHub.com.
  2. Choose HTTPS for Git operations (recommended).
  3. Choose Login with a web browser and follow the code flow (enter code at github.com/login/device).
Check GitHub auth
$
gh auth status

The Workflow

01

Initialize

Create a new local repository. This tells Git to start watching your folder.

Run once per project
$
git init
02

Staging

Select the files you want to save. The . adds everything.

Add all files
$
git add .
03

Commit

Wrap your changes in a package with a label. Be descriptive.

Save snapshot
$
git commit -m "First commit"
04

Connect

Link your local repo to the specific GitHub URL. This builds the bridge.

Set Destination
$
git remote add origin <URL>
05

Liftoff

Send your commits to the cloud. The -u remembers where you pushed for next time.

Upload to Github
$
git push -u origin main

JAVA EDITION

Scenario: You wrote your first Hello World and need to flex it.

0. The Context

You have a file named Main.java.

public class Main {
    public static void main(String[] args) {
      System.out.println("Hello World");
    }
}

1. Initialize

Turn this folder into a repository.

$
git init
Screenshot

2. Stage File

Tell git to track your Java file.

$
git add Main.java
Screenshot

3. Commit

Save the version history.

$
git commit -m "Added hello world"
Screenshot

4. Connect Remote

Point your local folder to your GitHub URL.

$
git remote add origin https://github.com/you/repo.git
Screenshot

5. Push Code

Send it to the internet.

$
git push -u origin main
Screenshot
REPOSITORY GALLERY
Img 1

Create a new repository

Img 2

Empty repository

Img 3

Initial commit

Img 4

Pushed files

Img 5

Branches

Img 6

Committed changes