Last active
April 24, 2020 19:32
-
-
Save zachawilson/af78ffd148cdf2a70fb1e3215a580996 to your computer and use it in GitHub Desktop.
Makes it possible to share a repo without sharing the history. This will create a branch in the original repo and push to a remote without the history. Inspiration came from: https://stackoverflow.com/questions/19641108/split-git-repo-in-a-squashed-public-and-initial-private
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| echo MUST be on branch dev-bridge | |
| read -p "Do you want to make branch dev-bridge? Y or N: " -n 1 -r | |
| echo # (optional) move to a new line | |
| if [[ $REPLY =~ ^[Yy]$ ]] | |
| then | |
| git checkout -b dev-bridge | |
| fi | |
| read -p "Are you on branch dev-bridge? Y or N: " -n 1 -r | |
| echo # (optional) move to a new line | |
| if [[ $REPLY =~ ^[Yy]$ ]] | |
| then | |
| echo | |
| else | |
| exit | |
| fi | |
| git cat-file -p dev-bridge \ | |
| | sed '1,/^$/d' \ | |
| | git commit-tree HEAD^{tree} \ | |
| | xargs git branch dev | |
| echo branch 'dev' made with no history | |
| echo will merge new 'dev' branch to create a bridge to common history | |
| echo merging... | |
| git merge -s ours dev --allow-unrelated-histories -m 'merge commit to build a bridge to dev' | |
| echo switching to branch 'dev' | |
| git checkout dev | |
| echo now run... | |
| echo git remote add dev -t dev git@github.com:SwitchCaseGroup/__repo__ | |
| echo git push dev | |
| exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment