Menu
×
     ❯   
HTML CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO W3.CSS C C++ C# BOOTSTRAP REACT MYSQL JQUERY EXCEL XML DJANGO NUMPY PANDAS NODEJS DSA TYPESCRIPT ANGULAR GIT POSTGRESQL MONGODB ASP AI R GO KOTLIN SASS VUE GEN AI SCIPY CYBERSECURITY DATA SCIENCE INTRO TO PROGRAMMING BASH RUST

Git Push Branch to Bitbucket


Push Branch to Bitbucket

This chapter explains how to push a branch from your local computer to Bitbucket.


Push a Branch to Bitbucket

Let's create a new local branch, make a change, and push it to Bitbucket.

Example

git checkout -b update-readme
Switched to a new branch 'update-readme'

Edit a file, then check the status:

Example

git status

Add and commit your changes:

Example

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

Push your branch to Bitbucket:

Example

git push origin update-readme

Bitbucket New Branch



Push and Set Upstream

Use this if your branch doesn't exist on Bitbucket yet, and you want to track it:

Example

git push --set-upstream origin update-readme

Force Push

Warning: This overwrites the branch on Bitbucket with your local changes. Only use if you understand the risks.

Example

git push --force origin update-readme

Delete Remote Branch

Remove a branch from Bitbucket:

Example

git push origin --delete update-readme

Push All Branches

Push all your local branches to Bitbucket:

Example

git push --all origin

Push Tags

Push all your tags to Bitbucket:

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.

Exercise?What is this?
Test your skills by answering a few questions about the topics of this page

Which command will push your current branch to the remote named 'origin'?





×

Contact Sales

If you want to use W3Schools services as an educational institution, team or enterprise, send us an e-mail:
sales@w3schools.com

Report Error

If you want to report an error, or if you want to make a suggestion, send us an e-mail:
help@w3schools.com

W3Schools is optimized for learning and training. Examples might be simplified to improve reading and learning. Tutorials, references, and examples are constantly reviewed to avoid errors, but we cannot warrant full correctness of all content. While using W3Schools, you agree to have read and accepted our terms of use, cookie and privacy policy.

Copyright 1999-2025 by Refsnes Data. All Rights Reserved. W3Schools is Powered by W3.CSS.