Added gitconfig

This commit is contained in:
Simon Gruber
2024-12-09 11:01:44 +01:00
commit af71fb6bca
2 changed files with 64 additions and 0 deletions

19
.gitconfig Normal file
View File

@@ -0,0 +1,19 @@
[user]
name = Simon Gruber
[fetch]
prune = true
[http]
sslbackend = openssl
[core]
autocrlf = true
excludesfile = D:\\Users\\Simon.Gruber\\Documents\\gitignore_global.txt
[push]
autoSetupRemote = true
[init]
defaultbranch = main
[advice]
skippedCherryPicks = false
[pull]
ff = only
[alias]
branches = !sh scripts/git-branches

View File

@@ -0,0 +1,45 @@
#!/bin/sh
usage() {
echo "Usage: git branches [-f FILTER] ACTION"
echo " -f FILTER Optional branch name filter (default: '*')"
echo " ACTION Command to execute for each branch"
echo " The current branch name is available via variable 'b' or 'branch'"
echo ""
echo "Example:"
echo " git branches -f 'feature/*' 'echo Processing branch: \$b'"
echo " git branches 'git push origin \$branch'"
}
# Default filter
filter='*'
# Parse arguments
while [ $# -gt 0 ]; do
case "$1" in
-f)
filter="*$2*"
shift 2
;;
-h|--help)
usage
exit 0
;;
*)
action="$1"
shift
break
;;
esac
done
if [ -z "$action" ]; then
echo "No action provided"
echo
usage
exit 1
fi
git branch --list "${filter}" --format='%(refname:short)' | while read -r branch; do
b="$branch" eval "$action"
done