toofishes.net

Git filter-branch magic

Git gives you the power to do just about everything. Unfortunately, it sometimes results in commands that look like this (I even broke it into lines for easier digestion):

git filter-branch -d /tmp/tmpfs/git-filter –env-filter
“export GIT_AUTHOR_NAME=‘Dan McGee’ GIT_AUTHOR_EMAIL='email@example.com
GIT_COMMITTER_NAME=‘Dan McGee’ GIT_COMMITTER_EMAIL='email@example.com’”
–index-filter “git rm –cached –ignore-unmatch miniterm.c”
–msg-filter “cat - && echo && echo ‘Signed-off-by: Dan McGee email@example.com’” HEAD

I had been keeping a local git repository with this mini-project of mine, but hadn’t really cared to keep the author correct on the commits, let alone have signoff lines. Because I wanted to get this out there to see if there was any interest, I wanted to clean up my repository a bit by fixing the author and committer, along with removing a file that really didn’t need to be there. The above command performed the magic necessary to do this.

Tags

See Also