Skip to content

Instantly share code, notes, and snippets.

@redthor
Last active November 13, 2017 12:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save redthor/93b2d59f40782c09c7e7d8873049dc09 to your computer and use it in GitHub Desktop.
Save redthor/93b2d59f40782c09c7e7d8873049dc09 to your computer and use it in GitHub Desktop.
remote="$1"
url="$2"
z40=0000000000000000000000000000000000000000
# Don't bother unless this is origin
if [ "$remote" != "origin" ]
then
exit 0
fi
# refs/heads/master 67890 refs/heads/foreign 12345
# Need
# git push <remote-many-repo> <target split.sh branch>:<remote-many-repo-branch>
# e.g. `git push svc-repo refs/heads/svc:master`
#
# If _this_ branch is `refs/heads/GLOWSYS-284-int-fix` then:
# `git push svc-repo refs/heads/svc:GLOWSYS-284-int-fix`
#
while read local_ref local_sha remote_ref remote_sha
do
if [ "$local_sha" = $z40 ]
then
# Handle delete
:
else
# refs/heads/GLOWSYS-284-int-fix -> GLOWSYS-284-int-fix
branchName=${local_ref##*/}
../splitsh-lite --prefix svc/ --target refs/heads/svc --progress
git push svc-repo refs/heads/svc:$branchName
fi
done
exit 0
wget https://github.com/splitsh/lite/releases/download/v1.0.1/lite_linux_amd64.tar.gz
tar xzf *gz
# Base dir
mkdir mono
cd mono
git init
echo -e "## README\nmonorepo" > README.md
git add .
git commit -m 'Initial commit'
# Split of svc dir under mono
mkdir svc
echo -e '## README\nsvc' > svc/README.md
git add .
git commit -m 'Initial commit for svc'
# The split
../splitsh-lite --prefix svc/ --target refs/heads/svc --progress
# To test locally and save on network requests
git init --bare ../svc.git
git remote add svc-repo ../svc.git/
git fetch svc-repo
git push svc-repo svc:master
# Check to see all is well
cd ..
git clone svc.git svc
cd svc
ls -l
git status
# Test again
cd ../mono
echo "Some changes" >> svc/README.md
git commit -am 'Update svc README'
../splitsh-lite --prefix svc/ --target refs/heads/svc --progress
git push svc-repo svc:master
# Back in svc
cd -
git pull
# should be all up to date
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment