git push: upload your work
From your computer to the internet, in one move.
git push sends your new commits to the remote — and -u on the first push makes every later push a one-word command.
01Connect before you push
Your local repository starts with no remote — it does not know the internet exists. First, introduce it to one: git remote add origin <url>. From that moment the nickname origin points at that URL, and every push and pull knows where to go. Check the wiring any time with git remote -v, which prints each remote's name and address.
git remote add origin https://github.com/you/my-project.git
git remote -vOn GitHub, after creating an empty repository, the site shows you exactly these two commands with your URL filled in. You copy them once and never think about it again.
02The first push explains itself
A brand-new remote is empty — it has no branches at all. So the first push has to say where and what: git push -u origin main means push to origin, the branch main. The -u remembers the pair — upstream — so that from now on, standing on main, a bare git push knows exactly what you mean.
Git answers with upload statistics you can safely ignore, and one line that matters: * [new branch] main -> main — the remote just gained your branch, its very first one.
git push -u origin main
git push03Pushing nothing new
Push with nothing to send and git answers Everything up-to-date — the remote already has every commit you have. Not an error; a confirmation. The healthy daily loop grows one step: work, commit, push, repeat. Pushing often means your backup is always fresh and teammates are never waiting on you.
Once pushed, your commits exist on the shared remote where others can see and build on them. Push finished, reviewed work; keep experiments on their own branch.
remote add origin <url> → push -u origin main → then just git push forever after. Two commands once, one word always.
Practice
A local project is ready. Publish it.
01.Connect the remote: add origin with the URL https://github.com/you/my-project.git
hint: Try: git remote add origin https://github.com/you/my-project.git
02.Push main to origin, with -u so it remembers.
hint: Try: git push -u origin main