fix: robust git cleanup in git-pull script

This commit is contained in:
2026-06-30 13:06:14 +08:00
parent 20abd5d0bb
commit 18fef514b3

View File

@@ -121,15 +121,22 @@ if (isset($_GET['remote'])) {
// 1. Check current status
execute("git status 2>&1");
// Delete untracked local git-pull.php in root directory if present
// Delete untracked local files that might cause merge conflicts
if (file_exists('git-pull.php')) {
echo "Cleaning up local untracked git-pull.php root file to prevent conflict...\n";
@unlink('git-pull.php');
echo "-----------------------------------------\n";
}
if (file_exists('public/optimize.php')) {
echo "Cleaning up local untracked public/optimize.php file to prevent conflict...\n";
@unlink('public/optimize.php');
echo "-----------------------------------------\n";
}
// Discard any local modifications on the server to prevent pull aborts
execute("git reset --hard HEAD 2>&1");
execute("git clean -fd 2>&1"); // Force clean untracked files and directories
// 2. Pull latest changes
execute("git pull origin main 2>&1");