This refresh.sh
script works fine for updating normal files to GitHub:
$ cat refresh.sh
#!/bin/bash
# refresh.sh - Update ~/HomA/src and then publish to GitHub
# Pass commit message as first parameter (referenced as "$1")
# First time usage:
# ~/HomA$ chmod a+x refresh.sh
# Requires two directories ~/HomA (development directory) and
# ~/HomA/src (the published clone)
# Make sure credentials are stored /a/17979600/6929343
# $ git config credential.helper store
# $ git push https://github.com/pippim/HomA.git
# Username: <type your username>
# Password: <type your password>
# ll ~/.git*
# -rw-rw-r-- 1 rick rick 106 Dec 28 2021 /home/rick/.gitconfig
# -rw------- 1 rick rick 67 Nov 29 15:45 /home/rick/.git-credentials
# -rw-rw-r-- 1 rick rick 23 Nov 16 2021 /home/rick/.gitignore
# -rw-rw-r-- 1 rick rick 12 Feb 19 2022 /home/rick/.gitkeep
# /home/rick/.git-credential-cache:
# total 16
# drwx------ 2 rick rick 4096 Nov 29 16:00 ./
# drwxr-xr-x 80 rick rick 12288 Dec 1 07:22 ../
if [ ! -d ~/HomA ] ; then
echo Requires directories ~/HomA and ~/HomA/src
exit 101
fi
if [ ! -d ~/HomA/src ] ; then
echo Requires directories ~/HomA and ~/HomA/src
exit 102
fi
if [ -z "$1" ] ; then
now=$(date)
commit_message="Refresh repository on: $now"
else
commit_message="$1"
fi
echo "=== COMMIT MESSAGE set to: '$commit_message'"
cd ~/HomA/src
echo
echo "=== PULLING: $PWD changes from github.com"
git pull
retVal=$?
if [ $retVal -ne 0 ]; then
echo "git pull FAILED with code: $retVal"
exit $retVal
fi
cd ~/HomA || exit 1 # In case it fails
cd ~/HomA/src
echo
echo "=== UPDATING: $PWD"
cp -r ~/HomA/bias.jpg .
cp -r ~/HomA/calc.py .
cp -r ~/HomA/computer.jpg .
cp -r ~/HomA/external.py .
cp -r ~/HomA/global_variables.py .
cp -r ~/HomA/homa_common.py .
cp -r ~/HomA/homa-indicator.py .
cp -r ~/HomA/homa.py .
cp -r ~/HomA/hs100.sh .
cp -r ~/HomA/image.py .
cp -r ~/HomA/laptop_b.jpg .
cp -r ~/HomA/laptop_d.jpg .
cp -r ~/HomA/message.py .
cp -r ~/HomA/monitor.py .
cp -r ~/HomA/sony.jpg .
cp -r ~/HomA/sql.py .
cp -r ~/HomA/tcl.jpg .
cp -r ~/HomA/timefmt.py .
cp -r ~/HomA/toolkit.py .
cp -r ~/HomA/x11.py .
git add bias.jpg
git add calc.py
git add computer.jpg
git add external.py
git add global_variables.py
git add homa_common.py
git add homa-indicator.py
git add homa.py
git add hs100.sh
git add image.py
git add laptop_b.jpg
git add laptop_d.jpg
git add message.py
git add monitor.py
git add sony.jpg
git add sql.py
git add tcl.jpg
git add timefmt.py
git add toolkit.py
git add x11.py
retVal=$?
if [ $retVal -ne 0 ]; then
echo "git add src/x11.py FAILED with code: $retVal"
exit $retVal
fi
# Pull the trigger and commit changes
git commit -m "$commit_message"
retVal=$?
if [ $retVal -ne 0 ]; then
echo "git commit -m FAILED with code: $retVal"
exit $retVal
fi
echo
echo "=== PUSHING: $PWD changes to github.com"
git push
retVal=$?
if [ $retVal -ne 0 ]; then
echo "git push FAILED with code: $retVal"
exit $retVal
fi
However it fails with symbolic files. For example, toolkit.py
was just changed but it didn’t refresh in GitHub:
$ refresh.sh "Begin Notebook Configuraation Tabs"
=== COMMIT MESSAGE set to: 'Begin Notebook Configuraation Tabs'
=== PULLING: /home/rick/HomA/src changes from github.com
Already up to date.
=== UPDATING: /home/rick/HomA/src
[main 3ca1dc5] Begin Notebook Configuraation Tabs
1 file changed, 441 insertions(+), 198 deletions(-)
=== PUSHING: /home/rick/HomA/src changes to github.com
Enumerating objects: 7, done.
Counting objects: 100% (7/7), done.
Delta compression using up to 8 threads
Compressing objects: 100% (4/4), done.
Writing objects: 100% (4/4), 5.82 KiB | 425.00 KiB/s, done.
Total 4 (delta 3), reused 0 (delta 0), pack-reused 0 (from 0)
remote: Resolving deltas: 100% (3/3), completed with 3 local objects.
To https://github.com/pippim/HomA
cc71a18..3ca1dc5 main -> main
────────────────────────────────────────────────────────────────────────────────────────────
$ ll toolkit.*
lrwxrwxrwx 1 rick rick 28 Oct 15 16:37 toolkit.py -> /home/rick/python/toolkit.py
-rw-rw-r-- 1 rick rick 136034 Dec 20 17:13 toolkit.pyc
────────────────────────────────────────────────────────────────────────────────────────────
$ ll ~/python/toolkit.py
-rw-rw-r-- 1 rick rick 224852 Dec 20 16:06 /home/rick/python/toolkit.py
I’ve reviewed various Q&A’s in Stack Overflow but haven’t found a similar question with suitable answer.
I’m updating this repo. It probably won’t help, but here is a screenshot of the source directory: