1
0

fix: enhance git pull handling in bootstrap script to manage local changes

This commit is contained in:
2025-08-04 20:51:13 -05:00
parent 73a38cfa55
commit ebfb4b965d

View File

@@ -9,14 +9,27 @@ echo "Starting dotfiles bootstrap..."
# Clone repo (new installs) or update for branch switching
if [ -d "$DOTFILES_DIR/.git" ]; then
echo "Updating existing dotfiles repo..."
git -C "$DOTFILES_DIR" pull --quiet
cd "$DOTFILES_DIR"
# Handle local changes if they exist
if ! git diff-index --quiet HEAD --; then
echo "Local changes detected:"
echo "1) Discard 2) Stash 3) Abort"
read -p "Choice (1-3): " choice
case $choice in
1) git reset --hard HEAD ;;
2) git stash push -m "Bootstrap $(date +%Y%m%d-%H%M)" ;;
*) echo "Aborted. Check 'git status' in $DOTFILES_DIR"; exit 1 ;;
esac
fi
git pull --quiet || { echo "Error: Failed to update repository"; exit 1; }
else
echo "Cloning dotfiles into $DOTFILES_DIR..."
git clone "$DOTFILES_REPO" "$DOTFILES_DIR"
cd "$DOTFILES_DIR"
fi
cd "$DOTFILES_DIR"
# Branch selection - allows choosing which version of dotfiles to install
# - New installs: git clone defaults to 'main', but you can switch to any branch
# - Existing installs: switch from current branch to a different one