Skip to content

Instantly share code, notes, and snippets.

@maxgfr
Last active July 13, 2023 14:41
Show Gist options
  • Save maxgfr/3b835ee86cef7ef5c5cdbdac06486ef6 to your computer and use it in GitHub Desktop.
Save maxgfr/3b835ee86cef7ef5c5cdbdac06486ef6 to your computer and use it in GitHub Desktop.
Bash / git config

Bash / Git config

Reduce your push time

Just edit your ~/.zshrc by adding at the bottom this line :

push() {
    git add -A && git commit -m $1 $2 && git push $2
}

Then you can push to github easily like this :

push 'name of my commit'
push 'name of my commit' --no-verify

Avoid to ignore case git

git config core.ignorecase false

Docker build on mac M1

docker buildx build --platform linux/arm64 -t test --no-cache --pull .

Git config

[user]
	name = maxgfr
	email = mail
	signingkey = 123
[core]
	ignorecase = false
	excludesfile = /Users/max/.gitignore
[rerere]
	enabled = true
[pull]
	ff = only
[alias]
	# Common aliases:
	br = branch
	ci = commit
	co = checkout
	st = status

	# Common branches aliases:
	dev = "!git co dev && git fp"
	d = dev
	main = "!git co main && git branch --set-upstream-to=origin/main main && git fp"
	m = main

	# Align the current forked project main branch with the original main one:
	align = "!git as && git M && git fetch -p upstream && git reset --hard upstream/main"

	# Add current diffs and stash them:
	add-stash = "!git add . && git stash"
	as = add-stash

	# Delete all non-main local branches:
	clean-branches = "!git br | grep -v "main" | grep -v "dev" | xargs git br -D"
	cb = clean-branches

	# Delete all main-merged local branches:
	clean-branches-only-merged = "!git M && git fp && git br --merged | grep -v '\\*' | xargs -n 1 git br -d"
	cbom = clean-branches-only-merged

	dump = cat-file -p

	# Edit last commit with the new diffs:
	fix = "!git add . && git commit --amend --no-edit"
	# Same with a force-push to the remote matching branch:
	fixp = "!git add . && git commit --amend --no-edit && git push origin HEAD -f"

	# Fetch remote (locally removing remote deleted branches) and pull remote
	# into current branch:
	fetch-pull = "!git fetch -p && git pull"
	fp = fetch-pull

	# Print a pretty log:
	hist = log --pretty=format:\"%h %ad | %s%d [%an]\" --graph --date=short

	# Migrate master branch to main one after remote renaming:
	mm = "!git branch -m master main && git fetch origin && git branch -u origin/main main && git remote set-head origin -a && git remote prune origin"

	# Force-push current branch:
	push-head = push origin HEAD
	ph = push-head

	# Force-push current branch:
	push-force = push origin HEAD -f
	pf = push-force

	# Pop last stashed diffs and reset their tracking:
	stash-pop = "!git stash pop && git reset"
	sp = stash-pop

	# Show current HEAD tags:
	tag-info = tag --points-at HEAD
	ti = tag-info

	type = cat-file -t

	# Force Git to include execution rights diff under Windows OS:
	x = update-index --chmod=+x
[commit]
	gpgsign = true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment