Remotes and GitHub Flow · Lesson 14 of 15
Fetch, pull and rejected pushes
Synchronize team work, inspect before merging, and handle non-fast-forward rejection correctly.
fetch downloads remote history and updates origin/* without changing your files. pull is roughly fetch followed by merge (or rebase by configuration). Separating them is calmer: fetch, inspect diff and log, then integrate deliberately.
Teammate pushes
fetch updates origin/main
inspect differences
merge/rebase then push
git init -q -b main echo "base" > app.txt git add app.txt git commit -q -m "Base" git remote add origin https://example.com/team/app.git git push -q -u origin main teammate app.txt "remote update" "Teammate update" git fetch origin git log --all --format=%s
If a teammate pushed while you built on an older base, the remote rejects your non-fast-forward push. Do not force automatically. Fetch, pull or merge, resolve conflicts, test, then push. The rejection protects someone else's work.
Quick question
Which command downloads updates without changing the working tree?
Exercise
Push main, let a teammate add remote, pull quietly, and print the file.
Expected output: remote
git init -q -b main echo "base" > app.txt git add app.txt git commit -q -m "Base" git remote add origin https://example.com/team.git git push -q -u origin main cat app.txt
Learn more from
Played 0 of 2 games
Sign in to save your progress and earn XP.