bugl
bugl
HomeLearnPatternsPathsSearch
HomeLearnPatternsPathsSearch

Loading lesson path

Learn/Git/Git and GitHub
Git•Git and GitHub

Git Push Branch to GitHub

Flash cards

Review the key moves

1/4
Core idea

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.

1Quick choice

Which statement best captures the main point of this lesson?

2Fill blank

Complete the missing token from the example code.

___ checkout -b update-readme
3Order

Put the learning moves in the order that makes the concept easiest to apply.

Push and Set Upstream
Push a Branch to GitHub
Push Branch to GitHub

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 status

Example

git add README.md
git commit -m "Update readme for GitHub"

Example

git push origin update-readme

Push 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-readme

Force 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-readme

Delete Remote Branch

Example

git push origin --delete update-readme

Push All Branches

Push all your local branches to GitHub:

Example

git push --all origin

Push Tags

Example

git push --tags

Troubleshooting

  • 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.

Previous

Git Pull Branch from GitHub

Next

Git GitHub Flow