Flash cards
Review the key moves
What is the main idea behind Git Push Branch to GitHub?
Lesson checks
Practice each idea before moving on
Short Mimo-style checks built from this lesson's code, terms, and sequence.
Which statement best captures the main point of this lesson?
Complete the missing token from the example code.
___ checkout -b update-readmePut the learning moves in the order that makes the concept easiest to apply.
Push Branch to GitHub
This chapter explains how to push a branch from your local computer to GitHub.
Push a Branch to GitHub
Let's create a new local branch, make a change, and push it to GitHub.
Example
git checkout -b update-readme
Switched to a new branch 'update-readme'Edit a file, then check the status:
Example
git statusExample
git add README.md
git commit -m "Update readme for GitHub"Example
git push origin update-readmePush and Set Upstream
Use this if your branch doesn't exist on GitHub yet, and you want to track it:
Example
git push --set-upstream origin update-readmeForce Push
Warning
This overwrites the branch on GitHub with your local changes. Only use if you understand the risks.
Example
git push --force origin update-readmeDelete Remote Branch
Example
git push origin --delete update-readmePush All Branches
Push all your local branches to GitHub:
Example
git push --all originPush Tags
Example
git push --tagsTroubleshooting
- Rejected push (non-fast-forward): Someone else pushed changes before you. Run git pull --rebase first, then try again.
- Authentication failed: Make sure you are logged in and have permission to push to the repository.
- Remote branch not found: Double-check the branch name and spelling.