Skip to content

Instantly share code, notes, and snippets.

@gkossakowski
Created October 21, 2011 16:03
Show Gist options
  • Save gkossakowski/1304215 to your computer and use it in GitHub Desktop.
Save gkossakowski/1304215 to your computer and use it in GitHub Desktop.
#Prepare sample repo
git init
echo "Foo" > README.txt
git add README.txt
git commit -m"Initial commit"
echo "Foo2" > README.txt
git add README.txt
git commit -m"Changed README"
git checkout -b otherbranch
echo "Foo3" > README.txt
git add README.txt
git commit -m"Changed README second time"
git checkout master
# Now create new branch for starless scripts
git symbolic-ref HEAD refs/heads/starrless
rm .git/index
git clean -fdx
# Copy over first commit
echo "script" > script
# Make first commit.
git add *
git commit -a -m "Binary file utilities"
# Grab Hash of early commit
monkeypatch=$(git log | grep "commit" | awk '{ print $2 }')
# Add grafts to the grafts file.
firstcommit=$(git log --reverse master | head -n 1 | awk '{ print $2 }')
# Create a graft for this commit...
echo "$firstcommit $monkeypatch" >> .git/info/grafts
# REWRITE HISTORY
git filter-branch --tag-name-filter cat -- --all
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment