Add configuration for git

- Add .config/git/config
  + Define aliases
  + Configure default behavior in various situations
  + Add user information with signing key
- Add .config/git/commit_msg_template.txt
- Add .config/git/ignore
- Integrate `git` aliases into the shell
This commit is contained in:
Alexander Hess 2026-06-11 18:32:27 +02:00
commit 721c2fd905
Signed by: alexander
GPG key ID: B46EDB4DFC26805D
21 changed files with 1122 additions and 66 deletions

54
.local/bin/git-clean-all Executable file
View file

@ -0,0 +1,54 @@
#!/bin/sh
# Reset the working directory to `HEAD` and remove everything not tracked,
# except the files listed in $KEEP in ~/.local/bin/git-clean-ignored
#
# This is irreversible, so the changes are shown first and confirmed,
# unless "--force" is passed
#
# Usage: git clean-all [--force]
set -eu
# `git` runs scripts on the `$PATH` in the current directory,
# whereas it runs "!" aliases at the top level of the repository
cd "$(git rev-parse --show-toplevel)"
case "${1:-}" in
--force) _forced=1 ;;
"") _forced=0 ;;
*) echo "Usage: git clean-all [--force]" >&2; exit 2 ;;
esac
if [ "$_forced" -ne 1 ]; then
echo "Tracked files to be reset to HEAD:"
git diff --stat HEAD || true
echo ""
echo "Untracked and ignored files to be removed:"
# Keep the "-e" flags in sync with the other two copies:
# - the "-e" flags of `clean-untracked` in ~/.config/git/config
# - `$KEEP` in ~/.local/bin/git-clean-ignored
git clean -x -d -n -e ".python-version" -e ".env"
echo ""
printf "This CANNOT be undone. Continue? [y/N] "
read -r _answer || _answer=""
case "$_answer" in
[yY] | [yY][eE][sS]) ;;
*) echo "Aborted" >&2; exit 1 ;;
esac
fi
git reset --hard
git clean-ignored
git clean-untracked