Skip to content

Instantly share code, notes, and snippets.

@pocc
Created June 28, 2018 21:53
Show Gist options
  • Save pocc/8f282d57bb9612e6a9cb4ccb16ad316c to your computer and use it in GitHub Desktop.
Save pocc/8f282d57bb9612e6a9cb4ccb16ad316c to your computer and use it in GitHub Desktop.
Converts a repo to a branch on another repo
#!/bin/bash
# This script will move the files in a repository into a branch in another repository
# arg 1 is file source repo 1, arg 2 is repo 2 that will get a new branch
# arg 3 is repo 1 name, arg 4 is repo 2 name, arg 5 is the branch name
# Get files
cd /tmp
git clone $1
git clone $2
cd $4
# Move project's git folder to parent, copy files over, and move it back
mv .git ..
rm -rf *
cp -rP ../$4/. .
rm -rf .git
mv ../.git .
# Create dev branch
git branch $5
git checkout $5
git add .
git commit -m "created $5 branch from $3"
git push -u origin $5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment