From 3297ba81b4ded6927e886c51b8f349baa43e4f9b Mon Sep 17 00:00:00 2001 From: druckdev Date: Fri, 12 Nov 2021 15:56:01 +0100 Subject: [PATCH] git:alias:track: Also list non-tracked remotes The alias now lists all local *and* all remote branches and displays how they are linked. The `sort -uk1,1` deletes all duplicate entries of remote branches as they could be listed as %(upstream) as well as %(refname) through the `refs/remotes/`. TODO: This deletes too many entries when multiple local branches track the same remote branch. (Why ever you should do that...) I guess this could be resolved by using `awk` for the uniqueness. --- .config/git/config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.config/git/config b/.config/git/config index df4f8e3..474b0e0 100644 --- a/.config/git/config +++ b/.config/git/config @@ -16,7 +16,7 @@ [alias] root = rev-parse --show-toplevel spull = "!__git_spull() { git pull \"$@\" && git submodule sync --recursive && git submodule update --init --recursive; }; __git_spull" - track = "!track() { git for-each-ref --format='%(upstream:short) <- %(refname:short)' refs/heads | sort | awk '{ print $3,$2,$1}' | column -t | sed 's/ *<- *$//'; }; track" + track = "!track() { git for-each-ref --format='%(upstream)%(if)%(upstream)%(then),%(end)%(refname)' refs/heads refs/remotes | sort -uk1,1 -t, | sed -E 's/(.*),(.*)/\\2,\\1/; s:(heads/[^,]*)$:\\1,:; s:^refs/remotes/:,:; s:refs/[^/]*/::g' | column -ts,; }; track" [status] submodulesummary = true [diff]