Git & GitHub

Git & GitHub

A Beginner's Guide.

If you have anything to do pertaining to do with IT or code, you have sure as hell come across the term 'git'. This is my first ever blog post, the goal of which is to help pure beginners to setup & get started with Git.


📘 Difference between Git & GitHub

  • Git and GitHub are both popular tools for software development, but they serve different purposes. Git is a version control system, while GitHub is a web-based hosting service for Git repositories.
  • Git is a free and open-source software that allows you to track changes in your code over time. It's a distributed version control system, which means that you can work on your code offline and then sync your changes with a remote repository.
  • GitHub is a web-based hosting service for Git repositories. It provides a number of features that make it easy to manage and collaborate on projects, including a GUI, web-based interface, notification system, code review system, and pull request system.

In short, Git is a tool for managing your code, while GitHub is a platform for hosting and collaborating on Git repositories.

GitGitHub
TypeVersion control systemWeb-based hosting service
CostFree and open-sourceFree for individuals, paid for businesses
FeaturesTrack changes, collaborate, manage projectsGUI, web interface, notifications, code review, PRs
OwnershipLinux FoundationMicrosoft

🗒️ Starting From Scratch

To get started with git, install it locally. For MacOS: brew install git. On Debian-based systems: sudo apt-get install git. Verify with git -v. Then configure:

1
2
git config --global user.name "Your Name"
git config --global user.email "your.email@example.com"

🥕 Configuring Git with GitHub

  • Login to GitHub and create a new empty repository (no .gitignore or README).
  • GitHub will require SSH keys for private repos.

SSH Setup

Generate a new SSH key pair:

1
2
ssh-keygen -t ed25519 -C youremail@service.com
# follow on-screen instructions & add a password for this key

Start the ssh-agent and add your key:

1
2
eval '$(ssh-agent -s)'
ssh-add ~/.ssh/id_keyname

On MacOS, save to Apple Keychain and update ~/.ssh/config:

1
2
3
4
5
eval '$(ssh-agent -s)'
ssh-add --use-apple-keychain ~/.ssh/id_keyname

# For zsh, add to ~/.zshrc:
eval '$(ssh-add -s)' && ssh-add $HOME/.ssh/id_keyname && clear

Add to your global git config ($HOME/.gitconfig):

1
2
3
4
Host github.com
  AddKeysToAgent yes
  UseKeyChain yes  # macOS only
  IdentityFile $HOME/.ssh/key_name

Copy your public key (cat ~/.ssh/id_keyname.pub) and add it to GitHub Settings > SSH & GPG Keys > Add New SSH Key.

💍 Your First Commit

Initialize a new local repo and connect it to GitHub:

1
2
3
4
mkdir -p My_Project && cd My_Project
git init
git remote add origin <URL>
git branch -M main

Create a file and push your first commit:

1
2
3
4
echo '## Hi Mom :)' >> README.md
git add README.md
git commit -m 'first commit'
git push -u origin main

Every subsequent push uses the same add → commit → push sequence.


And That's All She Wrote!

We learned what Git is, how it differs from GitHub, how to initialize a repo, configure SSH keys, and make your first commit. Go build something!