Gitbits
Contents
Two small utilities I have places into ~/bin
:
git-attic
Source: https://github.com/maximeh/dotfiles/blob/master/common/.bin/git-attic
#!/bin/sh
# git-attic [-M] [PATH] - list deleted files of Git repositories
#
# Use -M to not show renamed files, and other git-log options as you like.
git log --raw --no-renames --date=short --format="%h %cd" "$@" |
awk '/^[0-9a-f]/ { commit=$1; date=$2 }
/^:/ && $5 == "D" { print date, commit "^:" $6 }' |
less
Example
➜ kubernetes-the-hard-way git:(master) ✗ git log --raw --no-renames --date=short --format="%h %cd" "$@" |
awk '/^[0-9a-f]/ { commit=$1; date=$2 }
/^:/ && $5 == "D" { print date, commit "^:" $6 }'
2019-11-20 374e8d9^:docs/using-rst/pdp-template-rst.rst
2019-11-17 7911114^:src/certificates/admin-csr.json
2019-11-17 7911114^:src/certificates/admin-key.pem
2019-11-17 7911114^:src/certificates/admin.csr
2019-11-17 7911114^:src/certificates/admin.pem
2019-11-17 7911114^:src/certificates/ca-config.json
2019-11-17 7911114^:src/certificates/ca-csr.json
2019-11-17 7911114^:src/certificates/ca-key.pem
2019-11-17 7911114^:src/certificates/ca.csr
2019-11-17 7911114^:src/certificates/ca.pem
2019-11-17 7911114^:src/certificates/copy-certificates-to-servers.sh
git trail
I cannot remember where is this one from :-(
#!/bin/sh -e
# git trail [-r] [-t] [COMMIT] - show all branching points in Git history
[ "$1" = -r ] && shift || REMOTES="-e refs/remotes/"
[ "$1" = -t ] && shift || TAGS="-e refs/tags/"
COMMIT=$(git rev-parse --no-flags --default HEAD "$@")
{ git for-each-ref | grep -v -e '^$' $TAGS $REMOTES
git log --date=short --format="%cd %h %H" "$@"
} | awk '
$2 == "commit" || $2 == "tag" {
"git merge-base '$COMMIT' " $1 | getline mb
merge[mb] = merge[mb] " " $3
}
{
if ($3 in merge) {
split(merge[$3], mbs, " ")
for (i in mbs) {
"git name-rev --name-only --refs=\"" mbs[i] "\" " $3 | getline nr
if (nr != "undefined") print $1, $2, nr # skip unreachable commits
}
}
Author Miro Adamy
LastMod 2019-01-14
License (c) 2006-2020 Miro Adamy