118 lines
2.6 KiB
Bash
118 lines
2.6 KiB
Bash
|
#!/bin/bash
|
||
|
|
||
|
declaim () {
|
||
|
echo
|
||
|
echo ${*}
|
||
|
echo "==============="
|
||
|
echo
|
||
|
}
|
||
|
|
||
|
SCRIPT_DIR=$(cd $(dirname ${0}); pwd)
|
||
|
|
||
|
REPO_DIR=${SCRIPT_DIR}/simpleRepo
|
||
|
|
||
|
if [ ${#} -eq 1 ]; then
|
||
|
REPO_DIR=${1}
|
||
|
elif [ ${#} -gt 1 ]; then
|
||
|
exit
|
||
|
fi
|
||
|
|
||
|
declaim "Creating empty repository: ${REPO_DIR}"
|
||
|
rm -rf ${REPO_DIR}
|
||
|
mkdir -vp ${REPO_DIR}
|
||
|
cd ${REPO_DIR}
|
||
|
|
||
|
declaim "Initialising it as a git repository"
|
||
|
git init .
|
||
|
|
||
|
git config --local user.name "Gaius Julius Caesar"
|
||
|
git config --local user.email "gjcaesar@pontifexmaximus.rm"
|
||
|
|
||
|
declaim "Creating a text file"
|
||
|
cat <<EOF > information.md
|
||
|
|
||
|
# Test file
|
||
|
|
||
|
This is a file for demonstration purposes
|
||
|
|
||
|
EOF
|
||
|
|
||
|
declaim "Adding and commiting that text file. The first commit"
|
||
|
git add information.md
|
||
|
git commit -m "commit1"
|
||
|
|
||
|
declaim "Updating the text file"
|
||
|
echo "This is a second line of information." >> information.md
|
||
|
echo >> information.md
|
||
|
|
||
|
declaim "Adding and commiting that text file. The second commit"
|
||
|
git add information.md
|
||
|
git commit -m "commit2"
|
||
|
|
||
|
declaim "Updating the text file for the second time"
|
||
|
echo "This is a third line of information." >> information.md
|
||
|
echo >> information.md
|
||
|
|
||
|
declaim "Adding and commiting that text file. The third commit"
|
||
|
git add information.md
|
||
|
git commit -m "commit3"
|
||
|
|
||
|
declaim "Creating and checking out the Rel1 branch"
|
||
|
git checkout -b Rel1
|
||
|
|
||
|
declaim "Updating the text file on the Rel1 branch"
|
||
|
cat <<EOF >> information.md
|
||
|
|
||
|
# Rel1 information
|
||
|
|
||
|
This is more information added as part of Rel1
|
||
|
|
||
|
EOF
|
||
|
|
||
|
declaim "Adding and commiting that text file. The fourth commit"
|
||
|
git add information.md
|
||
|
git commit -m "commit4"
|
||
|
|
||
|
declaim "Updating the text file on the Rel1 branch again"
|
||
|
mv -v information.md{,.hold}
|
||
|
cat information.md.hold | sed 's/of Rel1$/of Rel1./' > information.md
|
||
|
rm information.md.hold
|
||
|
|
||
|
declaim "Adding and commiting that text file. The fifth commit"
|
||
|
git add information.md
|
||
|
git commit -m "commit5"
|
||
|
|
||
|
declaim "Creating and checking out the Rel2 branch"
|
||
|
git checkout master
|
||
|
git checkout -b Rel2
|
||
|
|
||
|
declaim "Updating the text file on the Rel2 branch"
|
||
|
mv information.md{,.hold}
|
||
|
cat <<EOF > information.md
|
||
|
|
||
|
# Rel2 information
|
||
|
|
||
|
This is more information added as part of Rel2
|
||
|
|
||
|
EOF
|
||
|
cat information.md.hold >> information.md
|
||
|
rm information.md.hold
|
||
|
|
||
|
declaim "Adding and commiting that text file. The sixth commit"
|
||
|
git add information.md
|
||
|
git commit -m "commit6"
|
||
|
|
||
|
declaim "Updating the text file on the Rel2 branch again"
|
||
|
mv information.md{,.hold}
|
||
|
cat information.md.hold | sed 's/of Rel2$/of Rel2./' > information.md
|
||
|
rm information.md.hold
|
||
|
|
||
|
declaim "Adding and commiting that text file. The seventh commit"
|
||
|
git add information.md
|
||
|
git commit -m "commit7"
|
||
|
|
||
|
declaim "Checking out master"
|
||
|
git checkout master
|
||
|
|
||
|
git log --oneline --graph --decorate --all
|