Skip to content

Instantly share code, notes, and snippets.

@cloud-walker
Last active February 17, 2023 13:49
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save cloud-walker/d1ea925dc24f0901a135c1ffeac5f028 to your computer and use it in GitHub Desktop.
Awesome GIT

Base configuration

Global for me: add them on ~/.gitconfig

[[filter "lfs"]
	clean = git-lfs clean -- %f
	smudge = git-lfs smudge -- %f
	process = git-lfs filter-process
	required = true
[init]
	defaultBranch = main
[pull]
	ff = only
[rerere]
  enabled = true
[alias]
	s = status -s
	lg = log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit
	unstage = reset HEAD --
	ua = unstage
	pushf = push --force-with-lease
	pullr = pull --rebase
	amend = commit --amend --no-edit
	df = diff --ignore-space-at-eol -b -w --ignore-blank-lines
	last = log -l HEAD
	branch-name = rev-parse --abbrev-ref HEAD
	publish = !git push -u origin $(git branch-name)
	unpublish = !git push origin :$(git branch-name)

	a = add
	ap = add -p
	c = commit --verbose
	ca = commit -a --verbose
	cm = commit -m
	cam = commit -a -m
	m = commit --amend --verbose

	# list branches sorted by last modified
	b = "!git for-each-ref --sort='-authordate' --format='%(refname)' refs/heads | sed -e 's-refs/heads/--'"

	# list aliases
	la = "!git config -l | grep alias | cut -c 7-"

	new = checkout -b

	# branch delete: This checks out your local master branch and deletes all local branches
	#                that have already been merged to master
	brd = !sh -c \"git checkout main && git branch --merged | grep -v '\\*' | xargs -n 1 git branch -d\"

	# branch delete here: Deletes all local branches that have already been merged to the branch
	#                     that you're currently on
	brdhere = !sh -c \"git branch --merged | grep -v '\\*' | xargs -n 1 git branch -d\"

rm -rf .git/rr-cache to completely remove the git rerere cache

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment