utils/bash/sources/31_git-utils

40 lines
859 B
Plaintext
Raw Permalink Normal View History

2022-08-11 15:24:41 +00:00
#!/bin/bash
function git-config-as {
local SHA NAME EMAIL
SHA=$1
if [ -z "$1" ]; then
SHA=HEAD
fi
NAME=$( git log $SHA -1 --pretty=format:%aN )
EMAIL=$( git log $SHA -1 --pretty=format:%ae )
git config user.name "$NAME"
git config user.email "$EMAIL"
echo "Configured as \"$NAME <$EMAIL>\""
}
2022-08-14 14:54:35 +00:00
function git-amend-author {
NAME=$( git config user.name )
EMAIL=$( git config user.email )
git commit --amend --no-edit --author "$NAME <$EMAIL>"
}
2022-08-11 15:24:41 +00:00
2022-08-11 16:19:32 +00:00
if [ ! -f "$HOME/.gitconfig" ]; then
2022-08-11 15:24:41 +00:00
cat << ___CONF___ > "$HOME/.gitconfig"
[alias]
la = log --graph --full-history --date-order --all --pretty=format:'%Cred%h%Creset %ad %C(bold blue)[%an]%Creset | %C(white)%s%Creset %C(yellow)%d%Creset' --date=relative
[color]
ui = auto
[core]
excludesfile = ~/gitignore
[push]
default = tracking
[credential]
helper = store
___CONF___
fi