Files
vps/dbg.clone
Михаил Капелько faf0c5b23d space
2025-11-09 06:39:21 +03:00

27 lines
665 B
Bash
Executable File

#!/bin/bash
SDIR=$(cd "$(dirname "$0")" ; pwd -P)
DST_DIR=/Users/mk/test-dist
MAIN_BRANCH=main
REPO_URL=https://github.com/kornerr/ru
TMP_BRANCHES=/tmp/dbg-branches
# Clone since the directory does not exist
if [ ! -d "$DST_DIR" ]; then
git clone $REPO_URL $DST_DIR
fi
# ?? Pull the latest changes
cd $DST_DIR
git checkout -f $MAIN_BRANCH
git fetch --all
# Find out the latest commit in the whole repo
git branch -av --sort=-committerdate
git branch -av --sort=-committerdate | tr -s ' ' | head -n1
cmt=`git branch -av --sort=-committerdate | tr -s ' ' | head -n1 | cut -d' ' -f4`
echo "Latest commit: $cmt"
# Switch to the latest branch
git checkout $cmt