Created
June 28, 2011 16:46
-
-
Save mfontani/1051568 to your computer and use it in GitHub Desktop.
git-rr: show which files were changed in commits, when rebasing
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/sh | |
# Usage: | |
# Once you started git rebase --interactive master, and you are presented | |
# with the list of commit SHAs and commit messages, from Vim: | |
# - visually select all SHAs via "V}k" | |
# - launch git-rr: !git-rr | |
# - ... | |
# - profit! you now have the same info as before, just with the list of | |
# filenames which changed with each commit, and can now move around | |
# commits knowing which files were touched by which commit | |
# Get current branch, without initial "heads/" | |
BRANCH=$(git describe --all | perl -lne's!^heads/!!;print') | |
# Kill the "git log" paging features | |
PAGER= | |
# Lines look like: | |
# * c0ffee00 commit message1 | |
# path/to/file1 | |
# <-= newline | |
# * 00c0ffee commit message2 | |
# path/to/file2 | |
# <-= newline | |
echo "### START Rebasing branch $BRANCH" | |
echo "###" | |
git log --reverse --pretty=format:'* %h %s' --abbrev-commit --stat --name-only master.. | perl -lne' | |
if ( m!^\*! ) { | |
s!^\*!pick ! # by default, show "pick" | |
} else { | |
s!^!# ! # just comment-out anything else, with leading spaces for filenames | |
} | |
s!\s*$!!; # kill any trailing spaces | |
' | |
echo "###" | |
echo "### END Rebasing branch $BRANCH" | |
echo "###" |
@akeeton see https://github.com/mfontani/los-opinionated-git-tools/blob/master/git-rr just updated with the bits which make it work properly both with a given branch/sha, and with the configuration to do the right thing automatically from a git rebase -i
, if one's using vim
as their editor. Hope this helps!
inspired from your script, I did it this way: https://github.com/cfconrad/scripts/blob/master/git/git-rb
It's basically the same, but I do not get the list of commits again, while just parsing the current buffer from stdin...
With this, I don't care about branches --autosqash
or rebase.instructionFormat
, cause I just don't touch it.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I'm sure I've updated this script since to take an optional branch as parameter, I'll dig it and update this gist. Check back ~Monday.