Skip to content

Instantly share code, notes, and snippets.

@malte0811
Created March 22, 2019 19:36
Show Gist options
  • Save malte0811/d36ea2dedc345cf41e1363dc9da4f23d to your computer and use it in GitHub Desktop.
Save malte0811/d36ea2dedc345cf41e1363dc9da4f23d to your computer and use it in GitHub Desktop.
A simple script to undo and redo commits, since IntelliJ currently likes to mess up line endings
MESSAGE=$(git log -1 --format=%s) ;
git reset --soft HEAD~1 ;
FILES=$(git status --porcelain | grep -v "?? " | sed 's/^\w*\ */ /' | sed 's/->//g' | sed ':a;N;$!ba;s/\n//g') ;
echo Files: $FILES ;
echo Message: $MESSAGE ;
git reset HEAD $FILES ;
git add $FILES ;
git commit -m "$MESSAGE" ;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment