Created
December 11, 2012 04:16
-
-
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
This file contains hidden or 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 | |
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 |
To setup as a Custom Action in SourceTree, go to Preferences->Custom Actions
:
- Click
Add
- Menu Caption:
fixup
- Script to run:
[path to git-fixup.sh]
- Parameters:
$SHA
You can then select a range of commits, right-click and choose Custom Actions->fixup
to squash all of the given commits with their parents
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
Can be used like this:
This will squash each of the given commits into its parent - useful to clean up bug-fix/syntax/reformatting/etc commits