Git & GitHub
Comprehensive notes for fresher developers joining the team.
What is Git?โ
Git is a distributed version control system (VCS) that tracks changes in your source code over time. It lets you save snapshots of your project, collaborate with teammates, and roll back to any previous state without losing work.
GitHub is a cloud-based hosting platform for Git repositories. It adds collaboration features on top of Git โ pull requests, code reviews, issue tracking, and project management.
| Feature | Git | GitHub |
|---|---|---|
| Type | Command-line tool (local) | Web platform (cloud) |
| Purpose | Track code changes | Host & collaborate on repositories |
| Works offline | Yes | No |
| Installed on | Your machine | Accessed via browser / CLI |
| Core feature | Version control | Pull requests, Issues, CI/CD |
Analogy: Git is like track-changes in a document editor. GitHub is like Google Docs โ it stores your document online and lets others view and edit it.
Learning Flowโ
| Phase | Topics |
|---|---|
| Phase 1 โ Setup & Core Concepts | Installation, GitHub account, SSH Authentication, Git Architecture, Basic Workflow |
| Phase 2 โ Essential Commands | init, clone, add, commit, status, log, diff, blame |
| Phase 3 โ Branching & Merging | Branches, Merge, Conflict Resolution |
| Phase 4 โ Remote Repositories | remote, push, pull, fetch, Forks |
| Phase 5 โ GitHub Collaboration | Pull Requests, Code Reviews, Issues, Branch Protection, GitHub Flow |
| Phase 6 โ Best Practices | Commit conventions, .gitignore, UOW Branching, Stash, Common Mistakes |
| Advanced Topics | Rebase, Interactive Rebase, Reset, Revert, Cherry-pick, Reflog, Tags & Releases, git bisect, git worktree, Hooks, Submodules, Signing commits, GitHub Actions |
Phase 1 โ Setup & Core Conceptsโ
1. Installation & Initial Configurationโ
Step 1 โ Create a GitHub account:
- Go to github.com and click Sign up
- Use your FortisureIT email address (
yourname@fortisureit.com) - Choose a username and complete email verification
- After signing in, go to Settings โ Password and authentication and enable Two-Factor Authentication (2FA) โ required for team access
Step 2 โ Install Git:
Download from https://git-scm.com/downloads and follow the installer. Use the recommended settings on each step.
After installing, open Git Bash (search "Git Bash" in the Windows Start menu) โ this is your terminal for running Git commands.
Verify the installation:
git --version
# git version 2.43.0
Step 3 โ Configure your identity (do this once on every machine):
git config --global user.name "your full name"
git config --global user.email "yourname@fortisureit.com"
Use your GitHub username and your FortisureIT email โ these are attached to every commit you make.
Step 4 โ Set your default branch name to main:
git config --global init.defaultBranch main
Step 5 โ Check your configuration:
git config --global --list
# user.name=your-github-username
# user.email=yourname@fortisureit.com
Note:
--globalapplies to all repositories on your machine. Omit it to configure only the current repository.
Optional โ Git GUI clients:
If you prefer a visual interface over the command line, these tools provide a graphical view of commits, branches, and diffs:
| Tool | Description |
|---|---|
| GitHub Desktop | Simple, official GitHub client |
| SourceTree | Feature-rich, shows branch graphs clearly |
| GitKraken | Visual and powerful, good for beginners |
Tip: Learn the command line first โ GUI clients are a supplement, not a replacement.
Practice: Git Installation Guide ยท First-Time Git Setup
2. Authenticating with GitHub โ SSH Setupโ
GitHub requires authentication every time you push, pull, or interact with a private or organisation repository. SSH keys are the recommended method โ you set them up once and never type a password again.
Why SSH over HTTPS? GitHub removed support for password-based HTTPS authentication in 2021. HTTPS now requires a Personal Access Token (PAT) โ a token you generate, copy, and manage yourself. SSH uses a cryptographic key pair stored on your machine: more secure, and completely seamless after the one-time setup. Always use SSH.
Step 1 โ Check for an existing SSH keyโ
Before generating a new key, check whether one already exists on your machine:
ls -al ~/.ssh
Look for files named id_ed25519.pub, id_rsa.pub, or id_ecdsa.pub. If you see one of these, you already have a key pair โ skip to Step 3.
Step 2 โ Generate a new SSH keyโ
ssh-keygen -t ed25519 -C "yourname@fortisureit.com"
-t ed25519โ the key algorithm. Ed25519 is the modern standard, preferred over the older RSA.-C "..."โ a comment/label so you can identify the key on GitHub.
You will be prompted:
Enter file in which to save the key (/c/Users/YourName/.ssh/id_ed25519):
โ Press Enter to accept the default location
Enter passphrase (empty for no passphrase):
โ Set a strong passphrase โ you will enter it once per session when the SSH agent loads
This creates two files in ~/.ssh/:
| File | Purpose |
|---|---|
id_ed25519 | Your private key โ never share this, never move it off your machine |
id_ed25519.pub | Your public key โ this is what you add to GitHub |
Security rule: The private key (
id_ed25519) must never leave your machine. Treat it like a password. Only the.pubfile is shared externally.
Step 3 โ Add the key to the SSH agentโ
The SSH agent holds your private key in memory so you don't have to enter your passphrase every time you push or pull.
# Start the SSH agent in the background
eval "$(ssh-agent -s)"
# Agent pid 1234
# Add your private key to the agent
ssh-add ~/.ssh/id_ed25519
# Enter passphrase for /c/Users/YourName/.ssh/id_ed25519: (enter it)
# Identity added: /c/Users/YourName/.ssh/id_ed25519 (yourname@fortisureit.com)
Make the agent start automatically on Windows (Git Bash):
Add these lines to your ~/.bashrc or ~/.bash_profile so the agent starts every time you open Git Bash:
# Auto-start SSH agent and load key on Git Bash launch
eval "$(ssh-agent -s)" > /dev/null
ssh-add ~/.ssh/id_ed25519 2>/dev/null
Step 4 โ Copy your public keyโ
# Print the public key to the terminal โ select all and copy manually
cat ~/.ssh/id_ed25519.pub
# Windows shortcut โ copy directly to clipboard
clip < ~/.ssh/id_ed25519.pub
The output looks like this (one long line):
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIAbc123...xyz yourname@fortisureit.com
Step 5 โ Add the public key to GitHubโ
- Go to github.com โ click your profile picture (top right) โ Settings
- In the left sidebar: SSH and GPG keys
- Click "New SSH key"
- Title: give it a descriptive name โ e.g.,
Work Laptop,Home PC - Key type: leave as
Authentication Key - Key: paste the public key you copied in Step 4
- Click "Add SSH key" โ confirm with your GitHub password or 2FA prompt if asked