- Skip problematic global .gitconfig in /var/www
- Use local repository config (.git/config) instead
- Avoids permission issues with /var/www directory
- Public repos don't need global config
- Simpler 4-step process with better error handling
- Create .gitconfig as www-data user (not root)
- Ensures file has correct owner and permissions from creation
- Add fallback to use local repository git config if global fails
- Prevents 'could not lock config file' permission errors
This fixes the issue where www-data user cannot write to root-owned files
For public repos, only minimal git config needed:
- Fix corrupted .gitconfig file
- Set git user.name and user.email (required by git)
- Remove unnecessary SSL and SSH configuration
- Fix directory permissions for www-data user
- Test git status
Removed:
- SSH key setup (not needed for public repos)
- SSL verification config (not needed for public HTTPS)
- HTTPS remote URL configuration (already correct)
Updated from 8 steps to 5 simpler steps
Enhanced error reporting:
- Show detailed diagnostic information: git version, user config, email, remote, branch
- Check .git directory and config file existence
- Detect if repository has uncommitted changes
- Error categorization: PERMISSION, CONFIG, REPO, NETWORK, SSL, GIT errors
- Actionable error messages with command suggestions
- Report raw error output to log file for debugging
Added setup_git_config.sh script:
- Automated configuration for www-data user
- Creates .ssh directory with proper permissions
- Sets git user.name and user.email globally
- Disables SSL verification (for HTTPS repos)
- Configures git to use HTTPS remote URL
- Fixes directory ownership and permissions
- Tests git status to verify configuration
Usage on live server:
sudo bash setup_git_config.sh
This script handles the common git configuration issues
that prevent 'Update HMS' button from working.