Skip to content

Instantly share code, notes, and snippets.

@vmiheer
Last active November 16, 2020 21:58
Show Gist options
  • Save vmiheer/3a2aefb97e2dcf62853cd60f59473b41 to your computer and use it in GitHub Desktop.
Save vmiheer/3a2aefb97e2dcf62853cd60f59473b41 to your computer and use it in GitHub Desktop.
Create github private fork
function private_clone() {
sourceRepo=$2
destOrg=$1
repoName=$(echo $sourceRepo | cut -d/ -f 2)
destRepo=$(echo $destOrg/$repoName)
gh repo create -y --private $destRepo
git clone --bare git@github.com:$sourceRepo\.git
cd $repoName\.git
git push --mirror git@github.com:$destRepo
cd ..; rm -rf $repoName\.git;
}
@vmiheer
Copy link
Author

vmiheer commented Nov 16, 2020

Use as:

$ private_clone <destOrg> <sourceRepo>
# sourceRepo looks like: cli/cli

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment