Skip to content

Instantly share code, notes, and snippets.

@daniel-fanjul-alcuten
Created May 1, 2012 12:27
Show Gist options
  • Save daniel-fanjul-alcuten/2567673 to your computer and use it in GitHub Desktop.
Save daniel-fanjul-alcuten/2567673 to your computer and use it in GitHub Desktop.
bup reset
#!/bin/bash
cd ~/.bup && {
git for-each-ref refs/heads/ --shell --format '
echo -n %(refname)...
commit=$(echo empty | git commit-tree `git mktree < /dev/null`)
for i in `git rev-list --since="2 week ago" --date-order --reverse %(refname)`; do
commit=$(git log -1 --pretty=format:%%B $i | GIT_AUTHOR_NAME=`git log -1 --pretty=format:%%an $i` \
GIT_AUTHOR_EMAIL=`git log -1 --pretty=format:%%aE $i` \
GIT_AUTHOR_DATE=`git log -1 --pretty=format:%%aD $i` \
GIT_COMMITTER_NAME=`git log -1 --pretty=format:%%cn $i` \
GIT_COMMITTER_EMAIL=`git log -1 --pretty=format:%%cE $i` \
GIT_COMMITTER_DATE=`git log -1 --pretty=format:%%cD $i` \
git commit-tree $i: -p $commit)
done
git update-ref -m "bup reset" %(refname) $commit %(objectname)
echo " ok"
' | bash
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment