Skip to content

Instantly share code, notes, and snippets.

@chsienki
Created September 15, 2020 16:48
Show Gist options
  • Save chsienki/f421ed5c6c69fbeb3ee6c8b40601478f to your computer and use it in GitHub Desktop.
Save chsienki/f421ed5c6c69fbeb3ee6c8b40601478f to your computer and use it in GitHub Desktop.
Git MRU Branches
[alias]
mru = "!git log -g -n 1000 --format=\"%gd %gs\" --date=relative HEAD@{now} | grep checkout | grep \" to\" | sed 's/HEAD@{\\(.*\\)}.* to\\(.*\\)/(\\1)\\t\\2/' | awk -v OFS=' ' '!x[$NF]++' | head -n 15 | column -ts $'\\t'" -R 1
@chsienki
Copy link
Author

chsienki commented Sep 15, 2020

Logs the last 1000 commit transitions, and prints the reflog subject and reflog date
Filters that by "HEAD@{[date]} checkout [a] to [b]"
Strips out the [date] and target branch [b]
Filters by unique branch names
Limits it to 15 entries
Prints it as a table with [date] [b]

@chsienki
Copy link
Author

Example output:

$ git mru
(16 hours ago)   sg_timing_info
(18 hours ago)   master
 (13 days ago)   sg_remove_obsolete_types
 (2 weeks ago)   sg_breaking_changes_doc
 (3 weeks ago)   sg_public_api
 (3 weeks ago)   sg_files_on_disk
 (3 weeks ago)   analyer_config_global_precedence2
 (3 weeks ago)   sg_no_framework
 (3 weeks ago)   sg_parse_options
 (3 weeks ago)   sg_wellknown_diagnostics
 (4 weeks ago)   sg_require_encoding
 (4 weeks ago)   sg_better_errors
 (4 weeks ago)   sg_output_files
 (5 weeks ago)   default_source_text_encoding
 (5 weeks ago)   cookbook_diagnostics

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