Remotes, GitHub & Push/Pull
Clone repos, push your work to GitHub, pull teammates' changes, and understand fetch vs pull
Knowledge Debt detected
You can study this freely — but your score may plateau if these foundations have gaps. The Mastery badge requires them to be solid.
Explanation
A is simply a URL your local repo knows about.
Clone an existing repo
git clone https://github.com/user/repo.git
# Creates a local copy with 'origin' pointing back to GitHubCheck remotes
git remote -v # list remotes and their URLs
# origin https://github.com/user/repo.git (fetch)
# origin https://github.com/user/repo.git (push)Push your branch
git push origin feature-login # push the branch
git push -u origin feature-login # push + set upstream (do once)
git push # after upstream is set, just thisFetch vs Pull
git fetch origin # download remote changes — does NOT modify your branch
git pull # fetch + merge into your current branch
git pull --rebase # fetch + rebase (cleaner history)Prefer `git fetch` then inspect before merging — it lets you see what changed before it touches your work.
Examples
First push of a new branch
The -u flag (set upstream) links your local branch to the remote branch so future git push and git pull know where to go.
git switch -c feature-payment
# ... make commits ...
git push -u origin feature-payment
# Sets 'origin/feature-payment' as the upstream
# Future: just 'git push'Sync with teammates before starting work
Always sync before branching off main so your feature branch starts from the latest code.
git switch main
git fetch origin # download new commits
git log origin/main # inspect what changed
git merge origin/main # apply — or: git pull does both
# Now your main is up to dateHow well did you understand this?
Next in Git & Version Control
Team Workflows & Best Practices