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>
Example
git clone https://github.com/username/project-name.git
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
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
Add all changes
git add .
6. git commit Command
A commit saves a snapshot of the staged changes into Git history.
Command
git commit -m "your message"
Example
git commit -m "Add index.html page"
Tips for commit messages
Good commit messages are:
- Short
- Clear
- Descriptive
Examples:
Add login pageFix navigation bugUpdate README
7. git push Command
git push uploads your commits to GitHub.
Command
git push
If it's your first push:
git push --set-upstream origin main
After that, you can simply run:
git push
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"
View your public key
cat ~/.ssh/id_ed25519.pub
Copy the key and add it to GitHub under:
Settings → SSH and GPG Keys
9. Useful Git Commands
Check repository status
git status
See commit history
git log
Check remote repository
git remote -v
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
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)