Skip to content

Instantly share code, notes, and snippets.

@mhart
Created December 11, 2012 04:16
Show Gist options
  • Save mhart/4255836 to your computer and use it in GitHub Desktop.
Save mhart/4255836 to your computer and use it in GitHub Desktop.
Script to fixup/squash commits given on a cmd line - can be used as a Custom Action in SourceTree
#!/bin/bash
lastCommit=""
editorCmd="sed -i ''"
for commit in $@; do
lastCommit=${commit:0:7}
editorCmd="$editorCmd -e 's/pick ${lastCommit}/fixup ${lastCommit}/'"
done
GIT_SEQUENCE_EDITOR=$editorCmd git rebase -i ${lastCommit}~2
@adamwong246
Copy link

Excellent! Now if only Source Tree would allow you to pass a new commit message to apply to the squashed commit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment