Skip to content

Instantly share code, notes, and snippets.

@letiesperon
Created June 29, 2021 14:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save letiesperon/ae3171e3797465a8b20c71881edab98b to your computer and use it in GitHub Desktop.
Save letiesperon/ae3171e3797465a8b20c71881edab98b to your computer and use it in GitHub Desktop.
My git local config to setup a new computer fast

My local git configs

Configure git author

  • 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

Configure git alias

  • 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'

Configure git global ignore

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment