fix: robust git cleanup in git-pull script
This commit is contained in:
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user