Skip to content

Instantly share code, notes, and snippets.

@devlead
Created October 29, 2015 17:30
Show Gist options
  • Save devlead/6a283af60a655b498edd to your computer and use it in GitHub Desktop.
Save devlead/6a283af60a655b498edd to your computer and use it in GitHub Desktop.
Example working with git log in PowerShell
# Get last 100 log entries as a PowerShell object
$gitHist = (git log --format="%ai`t%H`t%an`t%ae`t%s" -n 100) | ConvertFrom-Csv -Delimiter "`t" -Header ("Date","CommitId","Author","Email","Subject")
# Now you can do iterate over each commit in PowerShell, group sort etc.
# Example to get a commit top list
$gitHist|Group-Object -Property Author -NoElement|Sort-Object -Property Count -Descending
# Example do something for each commit
$gitHist|% {if ($_.Author -eq "Mattias Karlsson") {"Me"} else {"Someone else"} }
@devlead
Copy link
Author

devlead commented Jun 21, 2019

@monahancj glad you found it useful.

@TomasHubelbauer
Copy link

Yup, this rocks, thanks for putting this out here.

@galsi
Copy link

galsi commented Jul 12, 2021

thanks , simple and fast.

@Rhialto74
Copy link

Thank you!

@cal5barton
Copy link

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment