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
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'?