Remotes and GitHub Flow · Lesson 13 of 15
Remotes, push and tracking
Connect a local repository to a shared copy and push a branch safely.
A remote is a saved name for another repository's address. origin is merely a convention, not magic. git push -u origin main sends commits and records an upstream, so later git push knows the remote and branch.
Local main
push
tracking origin/main
shared repository
git init -q -b main echo "project" > README.md git add README.md git commit -q -m "Initial project" git remote add origin https://example.com/team/app.git git remote -v git push -u origin main
origin/main is a local reference to the last known remote main, not a branch you work on directly. Push transfers missing objects and asks the remote to advance its branch. Use SSH or HTTPS according to your organization.
Quick question
What does -u do on the first push?
Exercise
Create a repository and commit, add a remote named origin, then print detailed remotes.
origin https://example.com/app.git (fetch) origin https://example.com/app.git (push)
git init -q -b main echo "app" > app.txt git add app.txt git commit -q -m "Start" git remote -v
Learn more from
Played 0 of 2 games
Sign in to save your progress and earn XP.