Skip to content

Instantly share code, notes, and snippets.

@eduardosilva
Created February 5, 2024 18:39
Show Gist options
  • Save eduardosilva/3a6dbbfdbb36a2f15f2c83bb2eab50e9 to your computer and use it in GitHub Desktop.
Save eduardosilva/3a6dbbfdbb36a2f15f2c83bb2eab50e9 to your computer and use it in GitHub Desktop.
wip & rewip git alias
# This is Git's per-user configuration file.
[alias]
wip = "!sh -c \"WIP_STRING=\\\"wip: version\\\"; DEFAULT_VERSION=1; LAST_COMMIT_MSG=\\$(git log -1 --pretty=%B); LAST_VERSION=\\$(echo \\\"\\$LAST_COMMIT_MSG\\\" | grep -oP \\\"\\$WIP_STRING \\\\K\\\\d+\\\"); if [[ -z \\$LAST_VERSION ]]; then LAST_VERSION=\\$DEFAULT_VERSION; else LAST_VERSION=\\$((LAST_VERSION + 1)); fi; git add --all; git rm \\$(git ls-files --deleted) 2> /dev/null; git commit --message \\\"\\$WIP_STRING \\$LAST_VERSION\\\" --no-verify; echo \\\"wip commit created with version \\$LAST_VERSION\\\";\""
rewip = !git rebase -i HEAD~$(git log --grep=\"^wip\" --format=%h | wc -l)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment