Last active
May 12, 2017 07:25
-
-
Save tiborsimon/f02970b14d497029126381f630870889 to your computer and use it in GitHub Desktop.
Let's git a bit init file. Use it by executing it from the raw Gist: bash <(curl -fsSL https://gist.githubusercontent.com/tiborsimon/f02970b14d497029126381f630870889/raw)
This file contains 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
#!/usr/bin/env bash | |
header () { | |
local YELLOW=$(tput setaf 3) | |
local BOLD=$(tput bold) | |
local RESET=$(tput sgr0) | |
printf "\n${YELLOW}${BOLD}== $1 ==${RESET}\n" | |
} | |
log () { | |
local YELLOW=$(tput setaf 3) | |
local BOLD=$(tput bold) | |
local RESET=$(tput sgr0) | |
printf "${YELLOW}-> $1${RESET}\n" | |
} | |
find . | grep -v "init.sh" | xargs rm -rf 1>/dev/null 2>&1 | |
header "CREATING EMPTY REMOTE" | |
mkdir -p remote/super remote/sub-a remote/sub-b | |
cd remote/super && git init --bare && cd ../.. | |
cd remote/sub-a && git init --bare && cd ../.. | |
cd remote/sub-b && git init --bare && cd ../.. | |
header "INITIALIZING SUB-A.." | |
log "Cloning sub-a.." | |
git clone remote/sub-a | |
cd sub-a | |
log "Creating initial commit.." | |
echo "# Sub module A" > README.md | |
git add --all | |
git commit -m "Initial commit." | |
log "Pushing initial commit.." | |
git push -u origin master | |
cd .. | |
header "INITIALIZING SUB-B.." | |
log "Cloning sub-b.." | |
git clone remote/sub-b | |
cd sub-b | |
log "Creating initial commit.." | |
echo "# Sub module B" > README.md | |
git add --all | |
git commit -m "Initial commit." | |
log "Pushing initial commit.." | |
git push -u origin master | |
cd .. | |
header "INITIALIZING SUPER.." | |
log "Cloning super.." | |
git clone remote/super | |
cd super | |
log "Creating initial commit.." | |
echo "# Super" > README.md | |
git add --all | |
git commit -m "Initial commit." | |
log "Adding submodules.." | |
git submodule add ../sub-a | |
git submodule add ../sub-b | |
git commit -m "Submodules added." | |
log "Pushing changes.." | |
git push -u origin master | |
cd .. | |
header "REPO INITIALIZATION FINISHED!" | |
log "Removing local repositories.." | |
rm -rf super sub-a sub-b |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment