Skip to content

Instantly share code, notes, and snippets.

@hantoine
Last active July 12, 2024 14:45
Show Gist options
  • Save hantoine/8ded929f276938f505244adeb8a4c580 to your computer and use it in GitHub Desktop.
Save hantoine/8ded929f276938f505244adeb8a4c580 to your computer and use it in GitHub Desktop.
My git config
[user]
email =
name = Antoine Hébert
[alias]
cam = commit -am
s = status
ci = commit
pu = push
llg = log --graph --all --decorate
lg = log --graph --abbrev-commit --decorate --format=format:'%C(cyan)%h%C(reset) - %C(green)(%ar)%C(reset) %C()%s%C(reset) %C(cyan)- %an%C(reset)%C(yellow)%d%C(reset)' --all
co = checkout
br = branch
forcepush = push --force-with-lease
branchname = symbolic-ref --short HEAD
# Push the current branch to the remote "origin", and set it to track the upstream branch
publish = "!git push -u origin $(git branchname)"
# Delete the remote version of the current branch
unpublish = "!git push origin :$(git branchname)"
# Delete any branches that have been merged into master
delete-merged-branches = "!git main && git branch --merged | grep -v '\\*' | xargs -n 1 git branch -d"
# Unstage any files that have been added to the staging area
unstage = reset HEAD
cb = checkout -b
mainbranchname = !git symbolic-ref refs/remotes/origin/HEAD | cut -d'/' -f4
main = "!git checkout $(git mainbranchname)"
# Create new branch from latest main
nbm = "!f(){ git main && git pull && git cb $1 ; }; f"
# Rebase on origin
ro = "!git fetch && git rebase origin/$(git branchname)"
# Rebase on main
rebasemain = "!git main && git pull && git co - && git rebase $(git mainbranchname)"
# Merge main to branch
mergemain= "!git main && git pull && git co - && git merge $(git mainbranchname)"
# Commit an empty commit to rerun CI
rerun-checks = "commit -m \"chore: retrigger checks\" --allow-empty"
# Amend commit
update-commit = "commit -a --amend --no-edit"
# Delete current branch and go to main branch
brclean = "!br=$(git branchname) && git main && git br -d $br"
[pull]
rebase = false
ff = only
[init]
defaultBranch = main
[rebase]
updateRefs = true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment