{"id":1968,"date":"2021-07-02T09:00:00","date_gmt":"2021-07-02T09:00:00","guid":{"rendered":"https:\/\/gitprotect.io\/blog\/?p=1968"},"modified":"2024-10-30T11:10:48","modified_gmt":"2024-10-30T11:10:48","slug":"bitbucket-how-to-restore-deleted-branch","status":"publish","type":"post","link":"https:\/\/gitprotect.io\/blog\/bitbucket-how-to-restore-deleted-branch\/","title":{"rendered":"Bitbucket &#8211; Restore Deleted Branch Tips"},"content":{"rendered":"\n<p>You probably deleted a git branch more than once, but what will you do if it turns out that you need it afterward? Unfortunately, it happens that somebody can delete branches. In this case, we only need to restore this branch, no matter whether was it deleted accidentally or intentionally, right?<\/p>\n\n\n\n<!--more-->\n\n\n\n<p>But it is not always that easy. What if the git branch has also been removed from the remote repository? What is the best way to approach this problem? Should you remember anything important? And, finally what approach should you choose to solve this issue?<\/p>\n\n\n\n\n\n<h2 class=\"wp-block-heading\">A sneak peek at deleted branches<\/h2>\n\n\n\n<p>Deleted branches can become a great frustration for developers, especially if those branches contain important commits before <a href=\"https:\/\/gitprotect.io\/blog\/pull-request-vs-merge-request-whats-the-difference\/\" target=\"_blank\" rel=\"noreferrer noopener\">they are merged with other branches<\/a>. Moreover, maintaining a healthy Git repository requires an understanding of deleted branches and the ways to recover them.<\/p>\n\n\n\n<p>Well, a branch in Git is basically a reference to a particular commit. For example, when a branch is deleted, this reference is removed. Hence, commits still remain in the repository, but become unreachable&#8230; It may even seem that they are lost. Hovewer, hopefully, there is a way to recover these deleted branches and restore your work.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"the-problem-with-deleted-branches\">The problem&nbsp;with <strong>deleted branch<\/strong>es<\/h3>\n\n\n\n<p>Imagine a situation in which we are working on an important project. We get up early at dawn, i.e., after 11, drink coffee, do morning exercises, eat the bucket marked Breakfast I, and sit down at our workstation.<\/p>\n\n\n\n<p>After logging in, we realize that&nbsp;<strong>one of the key branches we worked on at an earlier time, which has a branch name \u201ckafj6\u201d, is no longer in the main repository<\/strong>, which means that someone used the&nbsp;<em>git push origin \u2013delete kaf6<\/em>&nbsp;command. At this point, we <a href=\"https:\/\/gitprotect.io\/blog\/automate-devops-tasks-devops-should-automate\/\" target=\"_blank\" rel=\"noreferrer noopener\">check<\/a> the local repo and contact the entire team to see if anyone has this branch on their local repository. Additionally, we check the repository directory for backups that might help recover the deleted branch. In case it turns out that someone on the team has a local copy, it is enough to send them to the server using the&nbsp;<em>git push<\/em>&nbsp;command.<\/p>\n\n\n\n<p class=\"has-background\" style=\"background-color:#f4fafe\">\ud83d\udca1 Do you know that identifying and locating the deleted branch is the first step in recovering it? There are several ways to do this &#8211; use <a href=\"https:\/\/gitprotect.io\/blog\/how-to-use-git-reflog-reflog-vs-log\/\" target=\"_blank\" rel=\"noreferrer noopener\">Git reflog<\/a>, Git log, or manual inspection of commits.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large is-resized\"><a href=\"https:\/\/gitprotect.io\/sign-up.html\" target=\"_blank\" rel=\"noopener\"><img decoding=\"async\" width=\"1024\" height=\"536\" src=\"https:\/\/gitprotect.io\/blog\/wp-content\/uploads\/2022\/03\/LinkedIn-ads-template-1024x536.png\" alt=\"Get free trial\" class=\"wp-image-2555\" style=\"width:512px;height:268px\" srcset=\"https:\/\/gitprotect.io\/blog\/wp-content\/uploads\/2022\/03\/LinkedIn-ads-template-1024x536.png 1024w, https:\/\/gitprotect.io\/blog\/wp-content\/uploads\/2022\/03\/LinkedIn-ads-template-300x157.png 300w, https:\/\/gitprotect.io\/blog\/wp-content\/uploads\/2022\/03\/LinkedIn-ads-template-768x402.png 768w, https:\/\/gitprotect.io\/blog\/wp-content\/uploads\/2022\/03\/LinkedIn-ads-template-400x209.png 400w, https:\/\/gitprotect.io\/blog\/wp-content\/uploads\/2022\/03\/LinkedIn-ads-template.png 1200w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure><\/div>\n\n\n<h3 class=\"wp-block-heading\" id=\"how-to-recover-deleted-branch\">How to recover deleted branch (Bitbucket)?<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>$ git log -p f3dadab\n\nAuthor: Kafej &lt;michal.zbyl@gmail.com&gt;\nDate:   Sat Jun 19 12:01:53 2021 +0200\n\n\tadd changes to line 2\n\ndiff --git a\/kafej.xml b\/kafej.xml\nindex f735f80..9ca37c4 100644\n--- a\/kafej.xml\n+++ b\/kafej.xml\n@@ -1 +1,2 @@\n-kafej\n\\ No newline at end of file\n+kafej\n+KafejDel\n\\ No newline at end of file\n\ncommit 1b202f57fefc235e7fedd59ed84e4551c90551d9\nAuthor: Kafej &lt;michal.zbyl@gmail.com&gt;\nDate:   Sat Jun 19 11:57:18 2021 +0200\n\n\tChange at line 1\n\ndiff --git a\/kafej.xml b\/kafej.xml\nnew file mode 100644\nindex 0000000..f735f80\n--- \/dev\/null\n+++ b\/kafej.xml\n@@ -0,0 +1 @@\n+kafej\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"listing-1-an-example-of-using-the-git-log-command-with-the-p-parameter\" style=\"font-size:14px\">Listing 1. An example of using the git log command with the p parameter.&nbsp;<\/h3>\n\n\n\n<p>Of course, we can use git commands like&nbsp;<em>git checkout -b kaf6 commit_hash<\/em>&nbsp;for our local repository typed in a command line, but what if we don&#8217;t know the hash for the last commit at this branch? We can use such commands as&nbsp;<em>git reflog<\/em>&nbsp;and check each commit with the&nbsp;<em>git log<\/em>&nbsp;command. In Listing 1, you can see an example of a&nbsp;<em>git log<\/em>&nbsp;command with -p flag.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ git init\n\n#Deleting local branch\n$ git branch -D kaf6\n\nDeleted branch kaf6 (was f3dadab).\n\n#Searching for commit hash\n$ git reflog\n\n1b202f5 (HEAD -&gt; master) HEAD@{0}: checkout: moving from kaf6 to master\nf3dadab HEAD@{1}: commit: add changes to line 2\n1b202f5 (HEAD -&gt; master) HEAD@{2}: checkout: moving from master to kaf6\n1b202f5 (HEAD -&gt; master) HEAD@{3}: commit: Change at line 1\n8c9440d (checkout) HEAD@{4}: reset: moving to 8c9440d\n8c9440d (checkout) HEAD@{5}: checkout: moving from kaf6 to master\n8c9440d (checkout) HEAD@{6}: checkout: moving from master to kaf6\n8c9440d (checkout) HEAD@{7}: reset: moving to 8c9440d52b42424ff9d40947c66639ed12a7d1e8\na8aa0f8 HEAD@{8}: reset: moving to a8aa0f86c48a89b89819bbd7065c79dd186ea7ce\na8aa0f8 HEAD@{9}: commit: add kafej.xml\n8c9440d (checkout) HEAD@{10}: revert: Revert \"Add file\"\n0672413 HEAD@{11}: commit (initial): Add file\n\n$ git reset --hard f3dadab\nHEAD is now at f3dadab add changes to line 2\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"listing-2-presentation-of-the-problem-and-solution-from-the-console-side\" style=\"font-size:14px\">Listing 2. Presentation of the problem and solution from the console side.<\/h3>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large is-resized\"><img decoding=\"async\" width=\"1024\" height=\"576\" src=\"https:\/\/gitprotect.io\/blog\/wp-content\/uploads\/2024\/03\/Disaster-Recovery-Use-Case-2-1024x576.jpg\" alt=\"Disaster Recovery Use Case\" class=\"wp-image-5177\" style=\"width:498px;height:auto\" srcset=\"https:\/\/gitprotect.io\/blog\/wp-content\/uploads\/2024\/03\/Disaster-Recovery-Use-Case-2-1024x576.jpg 1024w, https:\/\/gitprotect.io\/blog\/wp-content\/uploads\/2024\/03\/Disaster-Recovery-Use-Case-2-300x169.jpg 300w, https:\/\/gitprotect.io\/blog\/wp-content\/uploads\/2024\/03\/Disaster-Recovery-Use-Case-2-768x432.jpg 768w, https:\/\/gitprotect.io\/blog\/wp-content\/uploads\/2024\/03\/Disaster-Recovery-Use-Case-2-400x225.jpg 400w, https:\/\/gitprotect.io\/blog\/wp-content\/uploads\/2024\/03\/Disaster-Recovery-Use-Case-2-600x338.jpg 600w, https:\/\/gitprotect.io\/blog\/wp-content\/uploads\/2024\/03\/Disaster-Recovery-Use-Case-2-800x450.jpg 800w, https:\/\/gitprotect.io\/blog\/wp-content\/uploads\/2024\/03\/Disaster-Recovery-Use-Case-2.jpg 1200w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure><\/div>\n\n\n<div class=\"wp-block-buttons is-content-justification-center is-layout-flex wp-container-core-buttons-is-layout-1 wp-block-buttons-is-layout-flex\">\n<div class=\"wp-block-button has-custom-width wp-block-button__width-25\"><a class=\"wp-block-button__link has-white-color has-text-color has-background has-text-align-center wp-element-button\" href=\"https:\/\/gitprotect.io\/use-cases\/disaster-recovery.html\" style=\"background-color:#2558dc\" target=\"_blank\" rel=\"noreferrer noopener\">Find out more<\/a><\/div>\n<\/div>\n\n\n\n<p><\/p>\n\n\n\n<p>The problem appears when&nbsp;<strong>no one has a local copy of the missing local or remote branch<\/strong>, and we also deleted our version using the&nbsp;<em>git branch -d kaf6<\/em>&nbsp;command in a command line. At this point, we can rely on a manual search for a given local or remote branch using the&nbsp;<em>git reflog&nbsp;<\/em>command or&nbsp;<strong>restore a given branch from the backup<\/strong>. <\/p>\n\n\n\n<p>In the case of manual search using&nbsp;<em>reflog&nbsp;<\/em>tool, we must be aware that even <a href=\"https:\/\/gitprotect.io\/blog\/bitbucket-down-bitbucket-issues-thats-why-you-need-bitbucket-backup\/\">Bitbucket<\/a> in their official documentation recommends a full backup of our project before starting this process. This means that&nbsp;<a href=\"https:\/\/gitprotect.io\/bitbucket.html\" target=\"_blank\" rel=\"noreferrer noopener\">using the GitProtect.io solution will allow us to reverse the lost branch with one click<\/a>.<\/p>\n\n\n\n<p>In Listing 2, we can see that while the procedure itself is not complex, you must be very careful when performing it. Especially if we don&#8217;t have an implemented backup system, in this case, a mistake can cause us a lot of work. You can see it perfectly with the&nbsp;<em>git reflog show<\/em>&nbsp;command, which we will use when we&#8217;re not sure of the exact name of the deleted branch. In this case, we will try to \u201chit\u201d which change it was, but without certainty, we can only cause problems to us and our team. In Listing 2, we can see one more curiosity. That the branch was removed with the -D flag, not the -d flag, and this is related to our example.&nbsp;<strong>To delete a remote or local branch that is not fully merged yet, use the -D flag with&nbsp;<em>git branch -D branch_name<\/em>.<\/strong><\/p>\n\n\n\n<div style=\"height:20px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<hr class=\"wp-block-separator has-css-opacity\"\/>\n\n\n\n<p class=\"has-text-align-left\" style=\"font-size:22px\">How secure are your repos and metadata? Don&#8217;t push luck &#8211; <strong>secure your code with the first professional GitHub, Bitbucket, and GitLab backup<\/strong>.<\/p>\n\n\n\n<div class=\"wp-block-buttons is-layout-flex wp-block-buttons-is-layout-flex\">\n<div class=\"wp-block-button align=&quot;center&quot;\"><a class=\"wp-block-button__link has-background wp-element-button\" href=\"https:\/\/gitprotect.io\/sign-up.html\" style=\"border-radius:50px;background-color:#ff0300\" target=\"_blank\" rel=\"noreferrer noopener\">Start 14 days free GitProtect trial<\/a><\/div>\n<\/div>\n\n\n\n<hr class=\"wp-block-separator has-css-opacity\"\/>\n\n\n\n<div style=\"height:20px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"how-to-find-searched-branch-in-a-time-period\">How to find a searched branch in a time period?<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>$ git diff master@{0} kaf6@{1.day.ago}\n\nwarning: log for 'kaf6' only goes back to Sat, 19 Jun 2021 12:06:29 +0200\n\n$ git diff master@{0} master@{1.day.ago}\n\ndiff --git a\/kafej.xml b\/kafej.xml\ndeleted file mode 100644\nindex 9ca37c4..0000000\n--- a\/kafej.xml\n+++ \/dev\/null\n@@ -1,2 +0,0 @@\n-kafej\n-KafejDel\n\\ No newline at end of file\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"listing-3-demonstration-of-git-diff-command-with-a-time-range\" style=\"font-size:14px\">Listing 3. Demonstration of <em>git diff<\/em> command with a time range.<\/h3>\n\n\n\n<p>We can narrow down the&nbsp;<strong>search for a deleted branch<\/strong>&nbsp;by searching in a given time period. However, we have to be convinced when the branch we are looking for has been deleted. For example, if we know that the missing branch was in the git repository the day before, we can use the command&nbsp;<em>git diff branch_name @ {0} branch_name@hesive1.day.ago}<\/em>. We presented an example of using the&nbsp;<em>diff&nbsp;<\/em>utility in Listing 3.<\/p>\n\n\n\n<p><strong><strong>We can <a href=\"https:\/\/gitprotect.io\/blog\/can-git-restore-a-file\/\" target=\"_blank\" rel=\"noreferrer noopener\">restore a deleted branch<\/a> mainly in the three ways&nbsp;<\/strong><\/strong>described above, but the best and sure solution will be to restore them from a backup.&nbsp;GitProtect.io, with their product, will help in this task! Thanks to GitProtect.io, we will ensure that our projects are always safe and that failures or unforeseen events are not a blow to us.<\/p>\n\n\n\n<p class=\"has-background\" style=\"background-color:#f4fafe\"><a href=\"https:\/\/gitprotect.io\/bitbucket.html\" target=\"_blank\" rel=\"noreferrer noopener\"><strong>[FREE TRIAL] Ensure compliant Bitbucket backup and Disaster Recovery with a 14-day trial \ud83d\ude80<\/strong><\/a><br><a href=\"https:\/\/calendly.com\/d\/3s9-n9z-pgc\/gitprotect-live-demo?month=2024-10\" target=\"_blank\" rel=\"noreferrer noopener\"><strong>[CUSTOM DEMO] Let\u2019s talk about how backup &amp; DR software for Bitbucket can help you mitigate the risks<\/strong><\/a><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">How to prevent accidental deletion of Git branches<\/h2>\n\n\n\n<p>Well, it&#8217;s not a secret that it&#8217;s better to prevent the catastrophe than deal with it. So, let&#8217;s look at some tips that can help you prevent accidental deletion:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>use Git hooks<\/strong>, which can help you prevent the deletion of certain branches, e.g. you can set a pre-delete hook to block the deletion of a defined branch.<\/li>\n\n\n\n<li><strong>use permission management<\/strong>, which can help you limit who has permission to remove branches from your repository, preventing accidental or unauthorized deletions,<\/li>\n\n\n\n<li><strong>have a reliable <\/strong><a href=\"https:\/\/gitprotect.io\/blog\/bitbucket-backup-best-practices\/\" target=\"_blank\" rel=\"noreferrer noopener\"><strong>backup strategy for your Bitbucket<\/strong><\/a><strong> ecosystem<\/strong>, which allows you to have regular automated backups and ensure that you can restore a deleted branch and any critical Bitbucket data from accidental deletions or other <a href=\"https:\/\/gitprotect.io\/blog\/disaster-recovery-bitbucket-ecosystem-what-are-the-best-scenarios-use-cases-to-build-uninterrupted-workflow\/\" target=\"_blank\" rel=\"noreferrer noopener\">events of disaster<\/a>,<\/li>\n\n\n\n<li><strong>educate your team<\/strong> &#8211; train your team on how to use Git and other DevOps tools safely,<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Before you go:<\/h2>\n\n\n\n<p class=\"has-background\" style=\"background-color:#f4fafe\">\ud83d\udd0e Find out which <a href=\"https:\/\/gitprotect.io\/blog\/bitbucket-backup-best-practices\/\" target=\"_blank\" rel=\"noreferrer noopener\">Bitbucket backup best practices<\/a> to follow to make your critical data accessible and recoverable in any event of failure<br><br>\ud83c\udf1f See in practice! Read how <a href=\"https:\/\/gitprotect.io\/case-study-wharton.html\" target=\"_blank\" rel=\"noreferrer noopener\">the Wharton School of the University of Pennsylvania adopted GitProtect backups for Bitbucket<\/a> to ensure its data protection<br><br>\ud83d\udc40 Check out what <a href=\"https:\/\/gitprotect.io\/blog\/atlassian-security-incidents-2023-in-review\/\" target=\"_blank\" rel=\"noreferrer noopener\">security incidents and vulnerabilities Atlassian faced in 2023<\/a> and how the service provider was dealing with them<br><br>\u270d\ufe0f Subscribe to <a href=\"https:\/\/gitprotect.io\/gitprotect-newsletter.html?utm_source=blog&amp;utm_medium=blog\" target=\"_blank\" rel=\"noreferrer noopener\">GitProtect DevSecOps X-Ray Newsletter<\/a> and always stay tuned with the latest DevSecOps insights<br><br>\ud83d\udcc5 Schedule <a href=\"https:\/\/calendly.com\/d\/3s9-n9z-pgc\/gitprotect-live-demo?month=2024-03\" target=\"_blank\" rel=\"noreferrer noopener\">a live custom demo<\/a> and learn more about GitProtect backups for your Bitbucket ecosystem&nbsp;<br><br>\ud83d\udccc Or try <a href=\"https:\/\/gitprotect.io\/sign-up.html?utm_source=blog&amp;utm_medium=blog\" target=\"_blank\" rel=\"noreferrer noopener\">GitProtect backups for Bitbucket repositories and metadata<\/a> to eliminate data loss and guarantee business continuity<\/p>\n","protected":false},"excerpt":{"rendered":"<p>You probably deleted a git branch more than once, but what will you do if it turns out that you need it afterward? Unfortunately, it happens that somebody can delete branches. In this case, we only need to restore this branch, no matter whether was it deleted accidentally or intentionally, right?<\/p>\n","protected":false},"author":4,"featured_media":1972,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[],"class_list":["post-1968","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-bitbucket","post--single"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Bitbucket - Restore Deleted Branch Tips - Blog | GitProtect.io<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/gitprotect.io\/blog\/bitbucket-how-to-restore-deleted-branch\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Bitbucket - Restore Deleted Branch Tips - Blog | GitProtect.io\" \/>\n<meta property=\"og:description\" content=\"You probably deleted a git branch more than once, but what will you do if it turns out that you need it afterward? Unfortunately, it happens that somebody can delete branches. In this case, we only need to restore this branch, no matter whether was it deleted accidentally or intentionally, right?\" \/>\n<meta property=\"og:url\" content=\"https:\/\/gitprotect.io\/blog\/bitbucket-how-to-restore-deleted-branch\/\" \/>\n<meta property=\"og:site_name\" content=\"Blog | GitProtect.io\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/XoperoSoftware\/\" \/>\n<meta property=\"article:published_time\" content=\"2021-07-02T09:00:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-10-30T11:10:48+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/gitprotect.io\/blog\/wp-content\/uploads\/2021\/07\/how-to-restore-branch.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"600\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Michal Zbyl\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@GitProtectio\" \/>\n<meta name=\"twitter:site\" content=\"@GitProtectio\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Michal Zbyl\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"6 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/gitprotect.io\/blog\/bitbucket-how-to-restore-deleted-branch\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/gitprotect.io\/blog\/bitbucket-how-to-restore-deleted-branch\/\"},\"author\":{\"name\":\"Michal Zbyl\",\"@id\":\"https:\/\/gitprotect.io\/blog\/#\/schema\/person\/52a5c06583d6cc6e418c1afb37653017\"},\"headline\":\"Bitbucket &#8211; Restore Deleted Branch Tips\",\"datePublished\":\"2021-07-02T09:00:00+00:00\",\"dateModified\":\"2024-10-30T11:10:48+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/gitprotect.io\/blog\/bitbucket-how-to-restore-deleted-branch\/\"},\"wordCount\":1267,\"publisher\":{\"@id\":\"https:\/\/gitprotect.io\/blog\/#organization\"},\"image\":{\"@id\":\"https:\/\/gitprotect.io\/blog\/bitbucket-how-to-restore-deleted-branch\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/gitprotect.io\/blog\/wp-content\/uploads\/2021\/07\/how-to-restore-branch.png\",\"articleSection\":[\"Bitbucket\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/gitprotect.io\/blog\/bitbucket-how-to-restore-deleted-branch\/\",\"url\":\"https:\/\/gitprotect.io\/blog\/bitbucket-how-to-restore-deleted-branch\/\",\"name\":\"Bitbucket - Restore Deleted Branch Tips - Blog | GitProtect.io\",\"isPartOf\":{\"@id\":\"https:\/\/gitprotect.io\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/gitprotect.io\/blog\/bitbucket-how-to-restore-deleted-branch\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/gitprotect.io\/blog\/bitbucket-how-to-restore-deleted-branch\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/gitprotect.io\/blog\/wp-content\/uploads\/2021\/07\/how-to-restore-branch.png\",\"datePublished\":\"2021-07-02T09:00:00+00:00\",\"dateModified\":\"2024-10-30T11:10:48+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/gitprotect.io\/blog\/bitbucket-how-to-restore-deleted-branch\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/gitprotect.io\/blog\/bitbucket-how-to-restore-deleted-branch\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/gitprotect.io\/blog\/bitbucket-how-to-restore-deleted-branch\/#primaryimage\",\"url\":\"https:\/\/gitprotect.io\/blog\/wp-content\/uploads\/2021\/07\/how-to-restore-branch.png\",\"contentUrl\":\"https:\/\/gitprotect.io\/blog\/wp-content\/uploads\/2021\/07\/how-to-restore-branch.png\",\"width\":1200,\"height\":600,\"caption\":\"Bitbucket - how to restore deleted branch\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/gitprotect.io\/blog\/bitbucket-how-to-restore-deleted-branch\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Strona g\u0142\u00f3wna\",\"item\":\"https:\/\/gitprotect.io\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Bitbucket &#8211; Restore Deleted Branch Tips\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/gitprotect.io\/blog\/#website\",\"url\":\"https:\/\/gitprotect.io\/blog\/\",\"name\":\"GitProtect.io Blog\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/gitprotect.io\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/gitprotect.io\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/gitprotect.io\/blog\/#organization\",\"name\":\"GitProtect.io\",\"url\":\"https:\/\/gitprotect.io\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/gitprotect.io\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/gitprotect.io\/blog\/wp-content\/uploads\/2023\/05\/favicon-528x528-1.png\",\"contentUrl\":\"https:\/\/gitprotect.io\/blog\/wp-content\/uploads\/2023\/05\/favicon-528x528-1.png\",\"width\":528,\"height\":528,\"caption\":\"GitProtect.io\"},\"image\":{\"@id\":\"https:\/\/gitprotect.io\/blog\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/XoperoSoftware\/\",\"https:\/\/x.com\/GitProtectio\",\"https:\/\/www.linkedin.com\/company\/xopero-software\/\",\"https:\/\/www.youtube.com\/channel\/UCiEnl6n0mIO6w7twccz-l2w\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/gitprotect.io\/blog\/#\/schema\/person\/52a5c06583d6cc6e418c1afb37653017\",\"name\":\"Michal Zbyl\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/gitprotect.io\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gitprotect.io\/blog\/wp-content\/uploads\/2023\/05\/michal-zbyl_avatar-96x96.jpg\",\"contentUrl\":\"https:\/\/gitprotect.io\/blog\/wp-content\/uploads\/2023\/05\/michal-zbyl_avatar-96x96.jpg\",\"caption\":\"Michal Zbyl\"},\"url\":\"https:\/\/gitprotect.io\/blog\/author\/michal-zbyl\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Bitbucket - Restore Deleted Branch Tips - Blog | GitProtect.io","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/gitprotect.io\/blog\/bitbucket-how-to-restore-deleted-branch\/","og_locale":"en_US","og_type":"article","og_title":"Bitbucket - Restore Deleted Branch Tips - Blog | GitProtect.io","og_description":"You probably deleted a git branch more than once, but what will you do if it turns out that you need it afterward? Unfortunately, it happens that somebody can delete branches. In this case, we only need to restore this branch, no matter whether was it deleted accidentally or intentionally, right?","og_url":"https:\/\/gitprotect.io\/blog\/bitbucket-how-to-restore-deleted-branch\/","og_site_name":"Blog | GitProtect.io","article_publisher":"https:\/\/www.facebook.com\/XoperoSoftware\/","article_published_time":"2021-07-02T09:00:00+00:00","article_modified_time":"2024-10-30T11:10:48+00:00","og_image":[{"width":1200,"height":600,"url":"https:\/\/gitprotect.io\/blog\/wp-content\/uploads\/2021\/07\/how-to-restore-branch.png","type":"image\/png"}],"author":"Michal Zbyl","twitter_card":"summary_large_image","twitter_creator":"@GitProtectio","twitter_site":"@GitProtectio","twitter_misc":{"Written by":"Michal Zbyl","Est. reading time":"6 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/gitprotect.io\/blog\/bitbucket-how-to-restore-deleted-branch\/#article","isPartOf":{"@id":"https:\/\/gitprotect.io\/blog\/bitbucket-how-to-restore-deleted-branch\/"},"author":{"name":"Michal Zbyl","@id":"https:\/\/gitprotect.io\/blog\/#\/schema\/person\/52a5c06583d6cc6e418c1afb37653017"},"headline":"Bitbucket &#8211; Restore Deleted Branch Tips","datePublished":"2021-07-02T09:00:00+00:00","dateModified":"2024-10-30T11:10:48+00:00","mainEntityOfPage":{"@id":"https:\/\/gitprotect.io\/blog\/bitbucket-how-to-restore-deleted-branch\/"},"wordCount":1267,"publisher":{"@id":"https:\/\/gitprotect.io\/blog\/#organization"},"image":{"@id":"https:\/\/gitprotect.io\/blog\/bitbucket-how-to-restore-deleted-branch\/#primaryimage"},"thumbnailUrl":"https:\/\/gitprotect.io\/blog\/wp-content\/uploads\/2021\/07\/how-to-restore-branch.png","articleSection":["Bitbucket"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/gitprotect.io\/blog\/bitbucket-how-to-restore-deleted-branch\/","url":"https:\/\/gitprotect.io\/blog\/bitbucket-how-to-restore-deleted-branch\/","name":"Bitbucket - Restore Deleted Branch Tips - Blog | GitProtect.io","isPartOf":{"@id":"https:\/\/gitprotect.io\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/gitprotect.io\/blog\/bitbucket-how-to-restore-deleted-branch\/#primaryimage"},"image":{"@id":"https:\/\/gitprotect.io\/blog\/bitbucket-how-to-restore-deleted-branch\/#primaryimage"},"thumbnailUrl":"https:\/\/gitprotect.io\/blog\/wp-content\/uploads\/2021\/07\/how-to-restore-branch.png","datePublished":"2021-07-02T09:00:00+00:00","dateModified":"2024-10-30T11:10:48+00:00","breadcrumb":{"@id":"https:\/\/gitprotect.io\/blog\/bitbucket-how-to-restore-deleted-branch\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/gitprotect.io\/blog\/bitbucket-how-to-restore-deleted-branch\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/gitprotect.io\/blog\/bitbucket-how-to-restore-deleted-branch\/#primaryimage","url":"https:\/\/gitprotect.io\/blog\/wp-content\/uploads\/2021\/07\/how-to-restore-branch.png","contentUrl":"https:\/\/gitprotect.io\/blog\/wp-content\/uploads\/2021\/07\/how-to-restore-branch.png","width":1200,"height":600,"caption":"Bitbucket - how to restore deleted branch"},{"@type":"BreadcrumbList","@id":"https:\/\/gitprotect.io\/blog\/bitbucket-how-to-restore-deleted-branch\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Strona g\u0142\u00f3wna","item":"https:\/\/gitprotect.io\/blog\/"},{"@type":"ListItem","position":2,"name":"Bitbucket &#8211; Restore Deleted Branch Tips"}]},{"@type":"WebSite","@id":"https:\/\/gitprotect.io\/blog\/#website","url":"https:\/\/gitprotect.io\/blog\/","name":"GitProtect.io Blog","description":"","publisher":{"@id":"https:\/\/gitprotect.io\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/gitprotect.io\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/gitprotect.io\/blog\/#organization","name":"GitProtect.io","url":"https:\/\/gitprotect.io\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/gitprotect.io\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/gitprotect.io\/blog\/wp-content\/uploads\/2023\/05\/favicon-528x528-1.png","contentUrl":"https:\/\/gitprotect.io\/blog\/wp-content\/uploads\/2023\/05\/favicon-528x528-1.png","width":528,"height":528,"caption":"GitProtect.io"},"image":{"@id":"https:\/\/gitprotect.io\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/XoperoSoftware\/","https:\/\/x.com\/GitProtectio","https:\/\/www.linkedin.com\/company\/xopero-software\/","https:\/\/www.youtube.com\/channel\/UCiEnl6n0mIO6w7twccz-l2w"]},{"@type":"Person","@id":"https:\/\/gitprotect.io\/blog\/#\/schema\/person\/52a5c06583d6cc6e418c1afb37653017","name":"Michal Zbyl","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/gitprotect.io\/blog\/#\/schema\/person\/image\/","url":"https:\/\/gitprotect.io\/blog\/wp-content\/uploads\/2023\/05\/michal-zbyl_avatar-96x96.jpg","contentUrl":"https:\/\/gitprotect.io\/blog\/wp-content\/uploads\/2023\/05\/michal-zbyl_avatar-96x96.jpg","caption":"Michal Zbyl"},"url":"https:\/\/gitprotect.io\/blog\/author\/michal-zbyl\/"}]}},"_links":{"self":[{"href":"https:\/\/gitprotect.io\/blog\/wp-json\/wp\/v2\/posts\/1968","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/gitprotect.io\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/gitprotect.io\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/gitprotect.io\/blog\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/gitprotect.io\/blog\/wp-json\/wp\/v2\/comments?post=1968"}],"version-history":[{"count":12,"href":"https:\/\/gitprotect.io\/blog\/wp-json\/wp\/v2\/posts\/1968\/revisions"}],"predecessor-version":[{"id":5907,"href":"https:\/\/gitprotect.io\/blog\/wp-json\/wp\/v2\/posts\/1968\/revisions\/5907"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/gitprotect.io\/blog\/wp-json\/wp\/v2\/media\/1972"}],"wp:attachment":[{"href":"https:\/\/gitprotect.io\/blog\/wp-json\/wp\/v2\/media?parent=1968"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/gitprotect.io\/blog\/wp-json\/wp\/v2\/categories?post=1968"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/gitprotect.io\/blog\/wp-json\/wp\/v2\/tags?post=1968"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}