Last active
February 17, 2024 20:00
-
-
Save raylee/8e1cd40050f7d9d09fe9ba4e263f3f4c to your computer and use it in GitHub Desktop.
.gitconfig aliases to give an overview of all branches in a repository.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[alias] | |
# branches: List recent branches sorted by date | |
# ${COLUMNS} is the standard environment variable to use to get the terminal's width. Unfortunately | |
# git sanitizes that away. git 2.31 will have a way to keep that variable. For now, extract it from | |
# the environment via stty. The below adds 20 to that value to account for the overhead of ANSI | |
# color sequences. | |
branches = !git for-each-ref refs/heads \ | |
--color=always \ | |
--sort=-committerdate \ | |
--format='%(HEAD)%(color:bold blue)%(refname:short)|%(color:green)%(committerdate:relative)|%(color:blue)%(authorname)|%(color:reset)%(subject)' \ | |
| column -ts'|' \ | |
| bash -c '"cut -c1-$((20 + $(stty size -F /dev/stderr | cut -f2 -d\" \")))"' | |
# fetch-all: retrieve all branch data from the remote. This can download a lot of data! | |
fetch-all = "!f(){ git checkout --detach 2>/dev/null \ | |
&& git fetch --tags origin '+refs/heads/*:refs/heads/*' \ | |
&& git branches; }; f" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment