4 ms·
TL;DR Quick way to create work-in-progress commits: #!/bin/bash # Perform a work-in-progress commit # Add everything git add $(git rev-par
by mcluck 4y ago
TL;DR Quick way to create work-in-progress commits:
#!/bin/bash
# Perform a work-in-progress commit
# Add everything
git add $(git rev-parse --show-toplevel)
# If the latest commit is already a WIP, amend it
if [[ $(git show --pretty=format:%s -s HEAD) = "WIP" ]]; then
git amend --no-edit --no-verify
else
git commit -m "WIP" --no-verify
fi
I wanted a way to quickly commit everything in a branch without thinking about it. This comes up a lot when I'm working on something and either need to pivot to something else or I want to pull down a PR and verify it without losing my work. I also wanted the option to quickly switch back to that branch, pick up where I left off, and be able to drop it again just as quickly without muddying up the commit history.
This script automatically stages everything and commits it as "WIP". If it detects that the most recent commit was a "WIP" then it amends the previous commit. No more weird stashing just to avoid losing my place