Skip to content

Instantly share code, notes, and snippets.

@gamorales
Last active January 21, 2025 01:19
Show Gist options
  • Save gamorales/7be73f537815ad79255b9a401861e28b to your computer and use it in GitHub Desktop.
Save gamorales/7be73f537815ad79255b9a401861e28b to your computer and use it in GitHub Desktop.
git alias
[alias]
s = status
lg = log --graph --oneline --decorate --color --pretty=format:\"%C(auto)%h %d %Creset%s > %Cblue%cn %Creset [%Cgreen%cd%Creset]\"
usu = log --pretty=format:\"%cn committed %h on %cd\"
p = git status push origin feature/PTS-1355-mobile-redirect
pu = git status pull origin feature/PTS-1355-mobile-redirect
lgusu = log --graph --oneline --decorate --color --pretty=format:\"%C(auto)%h %d %Creset %s > %Cblue%cn %Creset\"
cm = "!f() { git commit -m \"PTS-$1: $2\"; }; f"
new = "!f() { \n if [[ \"$1\" =~ ^(issue|feature|devops)$ ]] && [[ \"$2\" =~ ^[0-9]+$ ]] && [[ \"$3\" =~ ^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*$ ]]; then \n git checkout -b \"$1/PTS-$2-$3\"; \n else \n echo \"Usage: git new <issue|feature|devops> <number> <text-with-dashes>\"; \n echo \"Example: git new feature 123 update-api-endpoint\"; \n return 1; \n fi; \n}; f"
del = "!f() { \n if [[ \"$1\" =~ ^(issue|feature|devops)$ ]] && [[ \"$2\" =~ ^[0-9]+$ ]] && [[ \"$3\" =~ ^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*$ ]]; then \n DELETE_FLAG=\"-d\"; \n if [[ \"$4\" =~ ^(-d|-D)$ ]]; then DELETE_FLAG=\"$4\"; fi;\n git branch $DELETE_FLAG \"$1/PTS-$2-$3\"; \n else \n echo \"Usage: git del <issue|feature|devops> <number> <text-with-dashes> [-d|-D]\"; \n echo \"Example (safe delete): git del feature 123 update-api-endpoint -d\"; \n echo \"Example (force delete): git del devops 456 improve-ci-cd -D\"; \n return 1; \n fi; \n}; f"
st-pop = "!f() { git stash pop "stash@{$1}"; }; f"
st-apply = "!f() { git stash apply "stash@{$1}"; }; f"
st-drop = "!f() { git stash drop "stash@{$1}"; }; f"
st-clr = stash clear
aliases = !git config --global --list | grep alias
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment