Wednesday, 15 September 2021

Accidental stash delete?

If you've accidentally deleted a stash then worry not, you can recover it like this (thanks to my colleague Matt for this tip):

  • Run this in Git Bash terminal

    git fsck --unreachable | grep commit | cut -d ' ' -f3 | xargs git log --merges --no-walk


    It'll return a list of deleted stashes, ordered by date.

  • Find the commit hash in the response and then update the commit hash in the below cmd and run it

    git update-ref refs/stash 4b3fc45c94caadcc87d783064624585c194f4be8 -m "My recovered stash"


  • Refresh your git client (sourcetree/gitkraken) and it should now be listed again under 'Stashes'!

Wednesday, 31 March 2021

Insert list of strings into temp table

create table #tempListOfThings ( thing varchar(50) )

INSERT INTO #tempListOfThings (thing) VALUES ('val1'), ('val2'), ...