Thursday, 9 December 2021

Using powershell to look for files and versions

 Yesterday I had a runtime problem which required me to find a file with a particular version because it wasn't clear where or how this error was being produced. I used powershell to find files of name x and list their versions.

Get-Childitem C:\Projects -Include system.linq.dll -Recurse | Foreach-Object { "{0}`t{1}" -f $_.FullName   [System.Diagnostics.FileVersionInfo]::GetVersionInfo($_).FileVersion }

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'), ...