- Setup your commit authors name and email:
git config --global user.name "Your Name"
git config --global user.email your@email.com
- Setup your git globals
git config --global --edit
git newpush "Fix some bug"
(add, commit with error message and push)
git config --global alias.newpush '!f() { git add . && git commit -m "$@" && git push origin HEAD ; }; f'
git repush
(add, ammend and push -f)
git config --global alias.repush '!f() { git add . && git commit --amend --no-edit && git push origin HEAD -f; }; f'
git pullclean
(checkout to master, pull, and delete merged branched)
git config --global alias.pullclean '!f() { git checkout master && git pull origin master && git branch --merged master | grep -v "\* master" | xargs -n 1 git branch -d && git branch; }; f'
git pullcleanm
(pullclean for main instead of master)
git config --global alias.pullcleanm '!f() { git checkout main && git pull origin main && git branch --merged main | grep -v "\* main" | xargs -n 1 git branch -d && git branch; }; f'
git config --global core.excludesFile '~/.gitignore'
Or, just cut and paste this in vim ~/.gitconfig
:
# This is Git's per-user configuration file.
[user]
name = Leti Esperon
email = esperonleticia@gmail.com
# Please adapt and uncomment the following lines:
# name = Leticia Esperon
# email = esperonleticia@gmail.com
[alias]
newpush = "!f() { git add . && git commit -m \"$@\" && git push origin HEAD ; }; f"
repush = "!f() { git add . && git commit --amend --no-edit && git push origin HEAD -f; }; f"
pullclean = "!f() { git checkout master && git pull origin master && git branch --merged master | grep -v \"\\* master\" | xargs -n 1 git branch -d && git branch; }; f"
pullcleanm = "!f() { git checkout main && git pull origin main && git branch --merged main | grep -v \"\\* main\" | xargs -n 1 git branch -d && git branch; }; f"
[core]
excludesfile = ~/.gitignore
ignorecase = false