Remotes and GitHub
Push a branch
Publish local commits and connect a new local branch to its remote counterpart.
8 minute lesson
Before pushing, inspect the local commits and remote configuration:
git status
git log --oneline --decorate -3
git remote -v
Publish a new local branch with:
git push -u origin add-search
Git sends objects the remote needs and asks it to update its add-search branch. A successful push also updates your origin/add-search remote-tracking reference.
The -u option records the upstream relationship. Later, plain git status, git push, and git pull can relate the local branch to that remote branch.
Verify it:
git status
git branch -vv
A push can be rejected when the remote branch contains commits your local branch does not have. Do not immediately force-push. Fetch, inspect the graph, and integrate or coordinate the remote work first.
Pushing does not make uncommitted or merely staged changes available remotely. Only commits are transferred.
Exercise: modify a file without committing it, then push. Confirm that the remote branch does not receive the working-tree edit.
Lesson completed