DEV Community

Kervie Sazon
Kervie Sazon

Posted on

Git & GitHub Learning Notes

Today I studied the basics of Git and GitHub. These are essential tools for developers to track code changes and collaborate with others. I’m writing these notes so I can quickly remember the workflow when I use them again.

1. What is Git?

Git is a version control system that helps developers:

  • Track changes in code
  • Revert to previous versions
  • Work on projects collaboratively

Instead of saving multiple copies of files, Git keeps a history of changes.

2. What is GitHub?

GitHub is a cloud platform that hosts Git repositories online. It allows developers to:

  • Store code remotely
  • Collaborate with teams
  • Share projects publicly

Think of it as Git + cloud storage + collaboration tools.

3. Cloning a Repository

Cloning means downloading an existing repository from GitHub to your local machine.

Command

git clone <repository-url>
Enter fullscreen mode Exit fullscreen mode

Example

git clone https://github.com/username/project-name.git
Enter fullscreen mode Exit fullscreen mode

After cloning, a folder with the project will be created on your computer.

4. The Basic Git Workflow

The typical Git workflow looks like this:

Edit files
   ↓
git add
   ↓
git commit
   ↓
git push
Enter fullscreen mode Exit fullscreen mode

5. git add Command

The git add command moves changes into the staging area.

The staging area is where you prepare files before committing them.

Add a specific file

git add index.html
Enter fullscreen mode Exit fullscreen mode

Add all changes

git add .
Enter fullscreen mode Exit fullscreen mode

6. git commit Command

A commit saves a snapshot of the staged changes into Git history.

Command

git commit -m "your message"
Enter fullscreen mode Exit fullscreen mode

Example

git commit -m "Add index.html page"
Enter fullscreen mode Exit fullscreen mode

Tips for commit messages

Good commit messages are:

  • Short
  • Clear
  • Descriptive

Examples:

  • Add login page
  • Fix navigation bug
  • Update README

7. git push Command

git push uploads your commits to GitHub.

Command

git push
Enter fullscreen mode Exit fullscreen mode

If it's your first push:

git push --set-upstream origin main
Enter fullscreen mode Exit fullscreen mode

After that, you can simply run:

git push
Enter fullscreen mode Exit fullscreen mode

8. SSH Key

An SSH key allows you to connect to GitHub securely without typing your username and password every time.

It works like a secure authentication key between your computer and GitHub.

Generate SSH key

ssh-keygen -t ed25519 -C "your_email@example.com"
Enter fullscreen mode Exit fullscreen mode

View your public key

cat ~/.ssh/id_ed25519.pub
Enter fullscreen mode Exit fullscreen mode

Copy the key and add it to GitHub under:

Settings → SSH and GPG Keys
Enter fullscreen mode Exit fullscreen mode

9. Useful Git Commands

Check repository status

git status
Enter fullscreen mode Exit fullscreen mode

See commit history

git log
Enter fullscreen mode Exit fullscreen mode

Check remote repository

git remote -v
Enter fullscreen mode Exit fullscreen mode

10. My Simple Daily Git Workflow

When working on a project, I will usually do:

git add .
git commit -m "describe what I changed"
git push
Enter fullscreen mode Exit fullscreen mode

Key Takeaways 🧠

  • git clone → download a repository
  • git add → stage files
  • git commit → save changes locally
  • git push → upload changes to GitHub
  • SSH key → secure authentication without passwords

Learning Git and GitHub felt confusing at first, but understanding the basic workflow (add → commit → push) makes it much easier. I’ll keep practicing these commands while working on small projects.

Next topics I want to learn:

  • Branching
  • Pull requests
  • Merging
  • Git collaboration workflows

Top comments (0)