From 6fa3e0c7d9a49d8a1da2756eea603dd2b096f672 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ricardo=20Magalh=C3=A3es?= Date: Sun, 27 Sep 2015 17:28:04 +0200 Subject: [PATCH] Add instructions to recover a deleted tag. --- README.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/README.md b/README.md index 9fca9e8..14dc0c5 100644 --- a/README.md +++ b/README.md @@ -55,6 +55,7 @@ For clarity's sake all examples in this document use a customized bash prompt in - [Delete/remove arbitrary commit](#deleteremove-arbitrary-commit) - [I want to delete a branch](#i-want-to-delete-a-branch) - [Delete tag](#delete-tag) + - [Recover a deleted tag](#recover-tag) - [Deleted Patch](#deleted-patch) - [Check if all commits on a branch are merged](#check-if-all-commits-on-a-branch-are-merged) - [I've no idea what I did wrong](#ive-no-idea-what-i-did-wrong) @@ -738,6 +739,23 @@ $ git tag -d $ git push :refs/tags/ ``` + +## Recover a deleted tag + +If you want to recover a tag that was already deleted, you can do so by following these steps: First, you need to find the unreachable tag: + +```sh +$ git fsck --unreachable | grep tag +``` + +Make a note of the tag's hash. Then, restore the deleted tag with following, making use of git's [update-ref](http://git-scm.com/docs/git-update-ref): + +```sh +git update-ref refs/tags/NAME +``` + +Your tag should now have been restored. + ## Deleted Patch