recover deleted tags

This commit is contained in:
Bhupesh-V 2021-04-12 13:24:46 +05:30
parent 170c2fc5ca
commit 09ee6a46ea

17
ugit
View file

@ -82,8 +82,8 @@ undo_git_reset() {
git reset "$last_good_state"
}
# WIP (untested)
undo_git_merge() {
# WIP (untested)
if [[ "$1" == "conflicts" ]]; then
git merge --abort
elif [[ "$1" == "unpushed" ]]; then
@ -118,6 +118,21 @@ undo_git_stash_apply() {
git stash show -p | git apply --reverse
}
# WIP
recover_deleted_tag() {
# only works for annotead tags? :(
# git fsck --unreachable | grep tag
# to see changes git show <COMMIT_HASH>
# git update-ref refs/tags/<tag-name> <COMMIT_HASH>
COMMIT_HASH=$(git fsck --no-progress --unreachable | grep tag | cut -d ' ' -f3)
read -p "Enter Lost tag name: " -r TAG_NAME
if git update-ref refs/tags "$TAG_NAME" --create-reflog "$COMMIT_HASH"; then
echo "Tag $TAG_NAME Successfully Recovered"
git tag -l | grep "$TAG_NAME"
fi
}
case $option in
1) undo_git_commit;;
2) undo_git_push;;