When using Git with an Outlook email account, you may encounter issues with authentication due to Microsoft’s security policies. To configure Git to work seamlessly with your Outlook email, follow these steps:
Install git-credential-email
curl -L "https://github.com/AdityaGarg8/git-credential-email/releases/download/debian/KEY.gpg" | gpg --dearmor | sudo tee /etc/apt/trusted.gpg.d/git-credential-email.gpg >/dev/null && echo "deb [signed-by=/etc/apt/trusted.gpg.d/git-credential-email.gpg] \
https://github.com/AdityaGarg8/git-credential-email/releases/download/debian ./" | sudo tee -a /etc/apt/sources.list.d/git-credential-email.list && sudo apt-get update && sudo apt-get install -y git-credential-gmail git-credential-outlook git-credential-yahoo git-credential-aol git-msgraph git-protonmail
Setup a file-based keyring
sudo apt install python3-keyrings.alt -y
mkdir -p ~/.config/python_keyring && cat > ~/.config/python_keyring/keyringrc.cfg << 'EOF'
[backend]
default-keyring=keyrings.alt.file.PlaintextKeyring
EOF
Authenticate with git-credential-email
git credential-outlook --authenticate --device
This command will prompt you to log in to your Outlook account and authorize the application.
Configure Git to use git-credential-email
git config --global --edit
Add the following configuration to the Git config file:
[credential "smtp://smtp.office365.com:587"]
helper =
helper = outlook
[sendemail]
smtpserver = smtp.office365.com
smtpserverport = 587
smtpencryption = tls
smtpuser = xxx@outlook.com
from = xxx@outlook.com
smtpAuth = XOAUTH2 <-- use CAPITALS
smtpDomain = localhost
Now, you can use git send-email with your Outlook account.