π Homepage
β¬ οΈ Previous: π Basic Git Workflow
When working with Git and GitHub, itβs important to understand the difference between local and remote repositories.
A local repository exists on your own computer. It is where you:
git init my-project
cd my-project
touch index.html
git add .
git commit -m "Initial commit"
Now you have a Git repository only on your computer.
A remote repository is hosted on a server like GitHub. Itβs used to:
Backup your work online
Share code with others
Collaborate in teams
You can connect your local repo to GitHub: β Example:
git remote add origin git@github.com:username/my-project.git
git push -u origin main
This pushes your local changes to the remote GitHub repository.
Action | Command |
---|---|
Clone repo | git clone <repo-url> |
Add remote | git remote add origin <repo-url> |
Push changes | git push origin main |
Pull updates | git pull origin main |
Feature | Local Repository | Remote Repository |
---|---|---|
Location | On your device | On a server (e.g., GitHub) |
Access | Only you | Anyone with permission |
Purpose | Write & test code | Share & collaborate |
π‘ Tip: Always commit locally first, then push to remote to save and share your work.
β‘οΈUp Next: π Setting up SSH Keys