Skip to content

Instantly share code, notes, and snippets.

@nhoriguchi
Created November 12, 2014 16:22
Show Gist options
  • Save nhoriguchi/5cc5a97d2ea99993a4fd to your computer and use it in GitHub Desktop.
Save nhoriguchi/5cc5a97d2ea99993a4fd to your computer and use it in GitHub Desktop.
git-bundle test
#!/bin/bash
TMPF=$(mktemp -d)
SDIR=$TMPF/src
DDIR=$TMPF/dst
mkdir $SDIR $DDIR
commit_num() {
local num=$1
echo "data $num" > file
git add file
git commit -m "commit $num"
}
pushd $SDIR
git init
commit_num 1
commit_num 2
commit_num 3
#
# 1---2---3
# ^
# master
#
rsync -a $SDIR/ $DDIR
git branch sub_branch
commit_num 4
commit_num 5
commit_num 6
#
# 1---2---3---4---5---6
# ^ ^
# sub_branch master
#
git checkout sub_branch
commit_num 7
commit_num 8
commit_num 9
#
# .-7---8---9 <- sub_branch
# /
# 1---2---3---4---5---6
# ^
# master
#
git bundle create $TMPF/bundle master~3..master
file $TMPF/bundle
popd
pushd $DDIR
git bundle verify $TMPF/bundle
if [ $? -ne 0 ] ; then
echo "failed to verify your bundle" >&2
exit 1
fi
git remote add origin $TMPF/bundle
git pull origin master
git show
popd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment