GitHub Fundamentals
What is Git?
Git is a version control system used to track changes in your files. It allows undo, restore, and manage multiple versions ,helps multiple people work on the same project without conflict .
What is GitHub?
GitHub is a cloud platform where you can store your Git repositories online.
Git = tool on your computer
GitHub = website to store/share projects
How to install Git
Open terminal/cmd:
git --version
If not installed → download from official site.
Git Workflow Basics
Working directory → Staging → Repository
Working Directory are your actual files.
Staging — files marked to be saved.
Repository — final saved version in .git
Git Commands
- Initialize Git
git init
- Tell Git who you are
git config --global user.name "Your Name"
git config --global user.email "your@email.com"
- Check status
git status
- Add file(s) to staging
git add filename
or
add everything(all files) at a time :
git add .
- Commit (save) changes
git commit -m "Write a meaningful message"
Branching
Create a branch:
git branch feature1
To Switch to branch:
git checkout feature1
Create + switch together:
git checkout -b feature1
Merge branch:
git checkout main
git merge feature1
Connecting Git to GitHub
Step 1: Create a new repository on GitHub
Do NOT initialize with README (optional but recommended)
Step 2: Connect local repo to GitHub
git remote add origin https://github.com/yourusername/repoName.git
Step 3: Push code to GitHub
git push -u origin main
After first time:
git push
Pulling and Cloning
Clone someone else’s repo:
git clone https://github.com/user/repo.git
Pull (download new changes):
git pull
GitHub Collaboration Basics
Fork → Your own copy of someone’s repo
Pull Request (PR) → Request to merge your changes
Issues → Report bugs or improvements
Actions → Automate tests/deployments
Top comments (0)