Last active
November 6, 2021 10:52
-
-
Save fastzombies/d63cd953ea89f9f3499980688280d334 to your computer and use it in GitHub Desktop.
Simple demo of Integration-Manager workflow that can be used when services like Gitlab are not available.
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 | |
# This is a simple script to walk through the Integration-manager style of | |
# git workflow. Without a server such as gitlab, having only standard file | |
# system access, this is what is necessary. | |
demodir=~/repos/demo | |
gold=$demodir/repo-gold | |
silver=$demodir/repo-silver | |
bronze=$demodir/repo-bronze | |
sandbox=$demodir/repo-sandbox | |
# gold is production area and takes final approved changed from silver | |
# silver is gold staging area and takes changes from user bronze area | |
# bronze is individual user staging area for silver and is not for WIP | |
# sandbox is individual user sandbox where all WIP takes place | |
# if you have never used git, create some git configs | |
if [[ ! -e ~/.gitconfig ]]; then | |
# These are required | |
git config --global user.name "Your Name" | |
git config --global user.email "[email protected]" | |
# these are helpful | |
git config --global alias.glog 'log --oneline --decorate --all --graph' | |
git config --global alias.rlog 'log --oneline --decorate --all --reverse' | |
git config --global alias.ignore '"!gi() { curl -L -s https://www.gitignore.io/api/$@ ;}; gi"' | |
git config --global core.excludesfile ~/.gitignore_global | |
git config --global color.ui true | |
git config --global merge.tool vimdiff | |
fi | |
# create a .gitignore_global file to ignore vim swap files so git will not | |
# report them as untracked | |
if [[ ! -e ~/.gitignore_global ]]; then | |
git ignore >> ~/.gitignore_global | |
fi | |
### project area setup section ### | |
# make basic I-M structure | |
mkdir -pv $gold | |
mkdir -pv $silver | |
mkdir -pv $bronze | |
mkdir -pv $sandbox | |
# start a project. This is a top-down approach as if you had some code to start | |
# with and now want to get it inder SCM. You can also do it bottom up, this is | |
# just one way to do it. | |
proj=$gold/project | |
mkdir -p $proj && cd $proj && cd $proj | |
# populate project with some files | |
for dir in a b c d; do | |
mkdir -p $proj/dir-$dir && cd $proj/dir-$dir | |
for file in 0 1 2 3; do | |
echo " This is file${file}." > file-${file}.txt | |
done | |
cd $proj | |
done | |
# gold owner initializes the gold repo, tell silver owner when done | |
cd $proj | |
git init | |
git add * | |
git commit -m "Initial gold commit" | |
# silver owner initialize silver repo and tell users when done | |
cd $silver | |
git clone $proj | |
# users initialize their own bronze and sandbox repos | |
# Here will will auto create 4 user areas | |
for user in a b c d; do | |
# user-x created their bronze repo | |
#echo "-I- user-$user creating bronze" | |
mkdir -p $bronze/user-${user} && cd $bronze/user-${user} | |
git clone $silver/project | |
#user-x creates their sandbox | |
#echo "-I- user-$user creating sandbox" | |
mkdir -p $sandbox/user-${user} && cd $sandbox/user-${user} | |
git clone $bronze/user-${user}/project | |
# add gold repo and call it "gold" for pulling updates which will be covered later | |
#echo "-I- user-$user adding gold repo" | |
cd project | |
git remote add gold $gold/project | |
done | |
### change demo section ### | |
# user-a makes some changes | |
user=user-a | |
sbox=$sandbox/${user}/project | |
cd $sbox | |
# show remotes | |
git remote -v | |
# first get latest gold updates from the gold remote repo we added earlier | |
git pull gold master | |
# create and checkout a local dev branch, never work in master | |
git checkout -b my-dev-branch | |
# add and edit some files | |
echo "A new file from $user" > dir-a/file-4.txt | |
echo "An edit to a file" >> dir-b/file-0.txt | |
git status | |
git glog | |
#add updated and tracked files | |
git add -u | |
git status | |
git glog | |
# add new untracked files | |
git add dir-a/file-4.txt | |
git status | |
git glog | |
# commit changes | |
git commit -m "Some changes from $user" | |
git status | |
git glog | |
# merge with master | |
git checkout master | |
git merge my-dev-branch | |
git status | |
git glog | |
# [optional] delete dev branch. | |
git branch -D my-dev-branch | |
git glog | |
### pull changes to user-a bronze | |
cd $bronze/user-a/project | |
# set up remote | |
git remote -v | |
git remote add sandbox $sbox | |
git remote -v | |
git pull sandbox master | |
git status | |
git glog | |
### user-a email silver owner with "silver pull request for $bronze/user-a/project" | |
# silver integtation owner pull from bronze | |
cd $silver/project | |
# set up remote | |
git remote -v | |
git remote add user-a $bronze/user-a/project | |
git remote -v | |
git pull user-a master | |
git status | |
git glog | |
# user-a changes are now staged in silver | |
# user-b make changes | |
user=user-b | |
sbox=$sandbox/${user}/project | |
cd $sbox | |
# first get latest gold updates | |
git pull gold master | |
# now create and checkout working branch | |
git checkout -b dev | |
# add and edit some files | |
echo "A new file from $user" > dir-c/file-4.txt | |
echo "An edit to a file from $user" >> dir-d/file-0.txt | |
git status | |
git glog | |
#add updated and tracked files | |
git add -u | |
git status | |
git glog | |
# add new untracked files | |
git add dir-c/file-4.txt | |
git status | |
git glog | |
# commit changes | |
git commit -m "Some changes from $user" | |
git status | |
git glog | |
# merge with master | |
git checkout master | |
git merge dev | |
git status | |
git glog | |
# [optional] delete dev branch | |
git branch -D dev | |
git glog | |
# pull changed to user-a bronze | |
cd $bronze/user-b/project | |
git remote -v | |
git remote add sandbox $sbox | |
git remote -v | |
git pull sandbox master | |
git status | |
git glog | |
# user-a email silver owner with "silver pull request for $bronze/user-a/project" | |
# silver integtation owner | |
cd $silver/project | |
# vim will open asking for a merge comment. Edit if desired and ZZ or :wq to continue | |
git remote -v | |
git remote add user-b $bronze/user-b/project | |
git remote -v | |
git pull user-b master | |
git status | |
git glog | |
# silver owner email gold owner with "gold pull request for $silver/project" | |
# silver integtation owner | |
cd $gold/project | |
git remote -v | |
git remote add silver $silver/project | |
git remote -v | |
git pull silver master | |
git status | |
git glog | |
# user-a and user-b changes are now in prod | |
## end change demo | |
# git cheat sheet | |
# https://services.github.com/on-demand/downloads/github-git-cheat-sheet.pdf | |
# more comprehensive user guide | |
# https://git-scm.com/book/en/v2 | |
# a visual interactive guide to the git silos and the related functions | |
# http://ndpsoftware.com/git-cheatsheet.html |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment