Skip to content

Instantly share code, notes, and snippets.

@pseudomuto
Last active December 31, 2015 02:49
Show Gist options
  • Save pseudomuto/7922871 to your computer and use it in GitHub Desktop.
Save pseudomuto/7922871 to your computer and use it in GitHub Desktop.
Blog Code: Freezing and Thawing Git State
#!/bin/bash
count=0
if git commit -m "WIP [STAGED]" > /dev/null
then
let count+=1
fi
git add --all .
if git commit -am "WIP [UNSTAGED]" > /dev/null
then
let count+=1
fi
if [ $count -eq 0 ]
then
echo "nothing committed"
else
git log -n$count --pretty=format:'%Cgreen%h %Cred%an%Creset: %s'
fi
#!/bin/bash
if git rev-list HEAD -n1 --pretty="format:%s" | tail -n1 | grep "^WIP \[UNSTAGED\]$" > /dev/null
then
git reset HEAD^ > /dev/null
fi
if git rev-list HEAD -n1 --pretty="format:%s" | tail -n1 | grep "^WIP \[STAGED\]$" > /dev/null
then
git reset --soft HEAD^ > /dev/null
fi
git status --short
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment