You're on your way to the next level! Join the Kudos program to earn points and save your progress.
Level 1: Seed
25 / 150 points
1 badge earned
Challenges come and go, but your rewards stay with you. Do more to earn more!
What goes around comes around! Share the love by gifting kudos to your peers.
Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!
Join now to unlock these features and more
I (a long time ago) deleted a branch via the BitBucket Cloud Web page / app.
A remote team member (junior / new developer-in-training) was on leave - but now is back and has been committing and pushing code changes to the deleted branch.
(They do not have the skills / code / project oversight to do the merging.
I did think that I would just get them to switch to the new branch and merge in all their changes into it. But this is beyond their current skillset)
So I need to be able to checkout the remote branch to my machine, so that I can do the required merge(s) to get the new "main" brain up to date with his changes.
I have the remote path and the SHA of the last commit he pushed and tried the following;
git checkout -b origin/theDeletedPath <the commitSHA>
But I get an error that I can't resolve:
fatal: reference is not a tree: <the commitSHA>
The branch I want to recover does not appear in BitBucket Cloud (I have ensured that I am looking for ALL branches - not just active.
I have tried;
git branch -a -v
The latest commit/push to the deleted branch (unsurprisingly) does NOT appear in the commits for the repo, either.
I'd really appreciate any thoughts you might have.
If the remote branch has been deleted - you will not be able to push to the remote branch from your local.
I would suggest attempting to locate the local branch on the user's machine by running the git branch command to list only local branches.
Once this has been performed, you can then run a git checkout command to switch to the local branch and then push this to remote - once you push, this will create the origin/theDeletedPath linkage that you are expecting to see (if the branch name is different, you can rename the branch with git branch -m old_name new_name before pushing)
Unfortunately - if this data is lost and there is no local backup, our Cloud backups include the last 7 days of data in warm storage and any older is not easily recoverable.
Hope this helps.
- Ben (Bitbucket Cloud Support)