This commit is contained in:
Your Name
2024-02-17 19:02:33 -06:00
parent cf322c6e67
commit 0a4599280b
8 changed files with 357 additions and 52 deletions

35
update.sh Normal file
View File

@@ -0,0 +1,35 @@
# Set branch to your target branch
branch="oscarpilot"
# Fetch the latest changes from the remote repository for the target branch
git fetch origin "$branch"
# Check if the local branch is behind the remote branch
LOCAL=$(git rev-parse "@{0}")
REMOTE=$(git rev-parse "origin/$branch")
if [ "$LOCAL" != "$REMOTE" ]; then
echo "Local branch is behind; updating."
# Checkout the target branch forcefully, ignoring submodules as in the Python example
git checkout --force --no-recurse-submodules -B "$branch" "origin/$branch"
# Reset the local changes hard, clean the directory including untracked files and directories,
# and ensure submodules are in sync, updated, and also reset hard
git reset --hard
git clean -xdff
git submodule sync
git submodule update --init --recursive
git submodule foreach --recursive git reset --hard
echo "Repository and submodules have been updated and cleaned."
# Run git cleanup in the repository directory
git gc
git lfs prune
echo "Repository cleanup has been completed."
else
echo "Already at the latest version; no update needed."
fi