Last active
December 31, 2015 02:49
-
-
Save pseudomuto/7922871 to your computer and use it in GitHub Desktop.
Blog Code: Freezing and Thawing Git State
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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