Uninstall Git on Linux Agent¶
Overview¶
If you manually installed Git on your Linux agent and it's causing authentication issues, you can uninstall it and use the Git that comes with the Azure DevOps agent or the system package manager.
Check Current Git Installation¶
First, identify how Git was installed:
# Check Git version and location
which git
git --version
# Check if installed via package manager
dpkg -l | grep git # Ubuntu/Debian
rpm -qa | grep git # CentOS/RHEL
# Check if installed from source
ls -la /usr/local/bin/git
ls -la /opt/git
Uninstall Methods¶
Method 1: Uninstall via Package Manager (Recommended)¶
Ubuntu/Debian:
# Remove Git and related packages
sudo apt remove git git-core
sudo apt purge git git-core
sudo apt autoremove
# Verify removal
git --version # Should show "command not found" or use system Git
CentOS/RHEL:
Method 2: Remove Manually Installed Git¶
If Git was installed from source or manually:
# Find Git installation
which git
# Example output: /usr/local/bin/git
# Remove Git binary
sudo rm -f /usr/local/bin/git
sudo rm -f /usr/local/bin/git-*
# Remove Git man pages
sudo rm -rf /usr/local/share/man/man1/git*
sudo rm -rf /usr/local/share/man/man5/git*
sudo rm -rf /usr/local/share/man/man7/git*
# Remove Git documentation
sudo rm -rf /usr/local/share/doc/git*
# Remove Git configuration (if any)
sudo rm -rf /usr/local/etc/gitconfig
Method 3: Remove Git from Custom Location¶
If Git was installed to a custom location:
# Find all Git installations
find /usr -name git 2>/dev/null
find /opt -name git 2>/dev/null
find /usr/local -name git 2>/dev/null
# Remove found installations
sudo rm -rf /path/to/git/installation
Clean Up Git Configuration¶
After uninstalling, clean up any remaining Git configuration:
# Remove global Git config
rm -f ~/.gitconfig
rm -f ~/.git-credentials
# Remove system Git config (if exists)
sudo rm -f /etc/gitconfig
# Clean up any cached credentials
rm -rf ~/.git-credential-cache
Verify Uninstallation¶
# Check if Git is still accessible
which git
git --version
# Should show "command not found" or use system Git if still installed via package manager
Reinstall System Git (Optional)¶
If you need Git but want the system version:
Ubuntu/Debian:
CentOS/RHEL:
Restart Agent Service¶
After uninstalling Git, restart the agent service:
Notes¶
- The Azure DevOps agent includes its own Git, so you may not need a system-wide Git installation
- If you uninstall Git completely, ensure the agent's bundled Git is accessible
- Some pipelines may require Git to be in PATH - verify your pipeline requirements
- After uninstalling, test your pipelines to ensure they still work
Troubleshooting¶
If pipelines fail after uninstalling Git:
-
Check agent logs:
-
Verify agent can access repositories:
- Check if agent has proper permissions
-
Verify network connectivity to Azure DevOps
-
Reinstall Git if needed: