Last active
November 3, 2015 10:02
-
-
Save cu39/be34ba9d56b9c7dbebff to your computer and use it in GitHub Desktop.
Create a git repo whose last commit has four parents
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
#!/bin/sh | |
GIT=$(which git) | |
TARGET_DIR="four-parents" | |
if [[ -d $TARGET_DIR ]]; then | |
echo $TARGET_DIR already exists. | |
exit 1 | |
fi | |
$GIT init $TARGET_DIR && cd $TARGET_DIR | |
MSG_MASTER_1="1 on master" | |
echo "$MSG_MASTER_1" > master.txt | |
$GIT add -A && $GIT commit -m "$MSG_MASTER_1" | |
for BRANCH in alpha beta gamma | |
do | |
MSG="1 on $BRANCH" | |
$GIT checkout -b $BRANCH | |
echo "$MSG" > $BRANCH.txt | |
$GIT add -A && $GIT commit -m "$MSG" | |
$GIT checkout master | |
done | |
MSG_MASTER_2="2 on master" | |
echo "$MSG_MASTER_2" >> master.txt | |
$GIT commit -a -m "$MSG_MASTER_2" | |
$GIT merge -m "Merge branches 'alpha', 'beta', and 'gamma'" \ | |
alpha beta gamma | |
$GIT log --oneline --graph --decorate | |
$GIT cat-file -p HEAD | |
cd .. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment