Skip to content

Instantly share code, notes, and snippets.

@gidden
Last active August 29, 2015 14:13
Show Gist options
  • Save gidden/4588a48b91855b69d63c to your computer and use it in GitHub Desktop.
Save gidden/4588a48b91855b69d63c to your computer and use it in GitHub Desktop.
SWC Collaboration

This gist provides a minimal setup and example of the git collaborate exercise for SWC (e.g., here). Use setup.sh to get a minimal working repository example. A repos represent the master upstream version, B and C repos represent forks. *-remote directories represent Github repos (and forks), while ~*-local` directories correspond to local copies. exercise.sh goes through what students will see for both the PR execise and "experiencing a conflict".

#!/bin/bash
# initial updates
cd a-local
git checkout -b median
git push origin median
cd ..
cd b-local
git fetch upstream
git checkout median
cd ..
cd c-local
git fetch upstream
git checkout median
cd ..
# PR
cd b-local/
echo 'h' >> f
git commit -am "h"
git push origin median
git push c median
cd ../c-local/
git pull b median
cd ..
# merge conflict
cd a-local/
echo 'i' >> f
git commit -am 'i'
git push origin median
cd ../b-local/
git fetch upstream
git merge upstream/median
## this workflow follows for showing conflict in c
# emacs f
# git add f
# git commit -m "re-h"
# git push origin median
# cd ../c-local/
# git fetch upstream
# git merge upstream/median
# emacs f
# git add f
# git commit -m "re-h"
# git push origin median
# cd ../b-local/
# git pull c median
#!/bin/bash
# start clean
rm -rf a-local a-remote b-local b-remote c-local c-remote
mkdir a-local a-remote b-local b-remote c-local c-remote
# a-remote and local
cd a-remote/
git init --bare
cd ../
git clone a-remote a-local
cd a-local
touch f
git add f
git commit -m "f"
git push origin master
cd ..
# b-remote and local
git clone --bare a-remote b-remote
git clone b-remote b-local
cd b-local
git remote add upstream ../a-remote
git pull upstream master
git push origin master
cd ..
# c-remote and local
git clone --bare a-remote c-remote
git clone c-remote c-local
cd c-local
git remote add upstream ../a-remote
git pull upstream master
git push origin master
cd ..
# b and c remote adds
cd b-local
git remote add c ../c-remote
cd ..
cd c-local
git remote add b ../b-remote
cd ..
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment