[user] email = your_email name = your_username [alias] # view your global git config Aliases from CLI aliases = config --get-regexp '^alias\\.' # git clone cl = !git clone # Git shallow clone for large repos clq= !git clone --depth=1 s = status sw = switch co = checkout cob = checkout -b feat = "!f(){ git cob feature/${1}; };f" # Return the default branch for the repo i.e. master or main default = !git symbolic-ref refs/remotes/origin/HEAD | sed 's@^refs/remotes/origin/@@' del = branch -D br-clean = "!f() { DEFAULT=$(git default); git branch --merged ${1-$DEFAULT} | grep -v " ${1-$DEFAULT}$" | xargs git branch -d; }; f" br = branch --format='%(HEAD) %(color:yellow)%(refname:short)%(color:reset) - %(contents:subject) %(color:green)(%(committerdate:relative)) [%(authorname)]' --sort=-committerdate save = !git add -A && git commit -m undo = reset HEAD~1 --mixed # Saves work in an unreachable commit, just in case, THEN WIPES it from existance wipe = !git add -A && git commit -qm 'WIPE SAVEPOINT' && git reset HEAD~1 --hard done = "!f() { DEFAULT=$(git default); git checkout ${1-$DEFAULT} && git up && git br-clean ${1-$DEFAULT}; }; f" # Pretty log logs = !git log --pretty=format:\"%C(magenta)%h%Creset -%C(red)%d%Creset %s %C(dim green)(%cr) [%an]\" --abbrev-commit -30 last = log -1 HEAD cm = commit -m ci = commit st = stash pop = stash pop apply = stash apply # get config info i.e. git conf user.name conf = config --global # got user config i.e git user.name user = config --global user # quick work-in-progress commit wip = commit -am "WIP" # change commit message amend = commit -a --amend # Squash the last N commits. git squash 3, will reset the last 3 commits to the working directory then save them in a new commit squash = "!f(){ git reset --soft HEAD~${1} && git commit --edit -m\"$(git log --format=%B --reverse HEAD..HEAD@{1})\"; };f" # destage file(s) destage = restore --staged ## sync current feature branch with origin/develop syncod = !git fetch --all && git merge origin/develop ## sync current feature branch with given origin branch sync = "!f(){ git fetch --all && git merge origin/${1}; };f" # checkout develop branch dev = !git checkout develop # checkout the default branch i.e. master or main ma = "!f() { DEFAULT=$(git default); git checkout ${1-$DEFAULT}; }; f" master = !git checkout master main = !git checkout main dev = !git checkout develop up = !git pull --rebase --prune $@ && git submodule update --init --recursive # remove .git folder, maybe you `git init` in the wrong place deinit = !rm -rf .git # remove cache / cached file/directory decache = !git rm -r --cached [push] default = current # automatically setup remote branch tracking without --set-upstream-branch autoSetupRemote = true [pull] default = current rebase = false [init] defaultBranch = main [branch] autosetuprebase = never