🎓 A1Learner
🔍
0 of 50 lessons completed

Push to GitHub

Push sends your snapshots to the remote. It is how your work reaches GitHub and other people.

Send the branch the first time

The first push creates the branch on the remote and links it.

$ git push -u origin main

Send the next snapshot

The range shows which snapshots travelled.

$ git push origin main

Example

$ git push -u origin main

Key points

  • Push with a remote name and a branch name.
  • The first push uses -u to link the branch to the remote.
  • The link means later pushes need no names at all.
  • Push only sends snapshots. Unfinished work stays behind.
  • Git prints the range it sent, like d0728e6..25e1956.
  • The remote name origin and the branch main are the usual pair.
  • GitHub is a website that hosts remotes. The address there starts with https or git@.

Here, the first push creates the branch on the remote. The last line says main now tracks origin/main, so the next push needs no -u.

Note

Push never deletes the remote’s other branches.

Try it Yourself

Edit the code, then press Run.

Running is simulated

Exercise

What does -u do on the first push?