Work with multible accounts
user.name, user.email and credentails are used based on folder prefix in path
[user]
name = standardAccount
email = standardAccount@example.com
[credential]
helper = store --file ~/.standardAccount-credentials
[includeIf "gitdir:**/userA*/**"]
path = ${HOME}/.userA_gitconfig[user]
name = userA_Account
email = userA@example.com
[credential]
helper = store --file ~/.userA-credentials- Go to GitHub Settings https://github.com/settings/apps
- Click on "Personal access tokens"
- Click on "Tokens (classic)"
- Click on "Generate new token"
- Copy the token and paste it into
.userA-credentials:
https://userA:userAToken@github.com
Git uses the following configuration structure:
Installation git config --system
User git config --global
Repository git config
The Windows Git installation activates Git Credential Manager (GCM) by default. This may conflict with your custom configurations.
Check your current settings with:
git config --list --show-origin
If needed, disable system-wide credential helper settings:
git config --system --unset credential.helper
git clone https://github.com/YourUsername/YourRepository.git userA_YourRepositoryOr initialize within ../userA_something/...
ATTENTION: This will change the commit hash and name - you may not want to do this if others have already used this.
git commit --amend --reset-authorgit rebase -i <commit-hash>^
# Change 'pick' to 'edit' for the corresponding commit
git commit --amend --reset-author
git rebase --continuegit filter-branch --env-filter '
if [ "$GIT_COMMITTER_EMAIL" = "old.email@example.com" ]; then
GIT_COMMITTER_NAME="New Name"
GIT_COMMITTER_EMAIL="new.email@example.com"
fi
if [ "$GIT_AUTHOR_EMAIL" = "old.email@example.com" ]; then
GIT_AUTHOR_NAME="New Name"
GIT_AUTHOR_EMAIL="new.email@example.com"
fi
' -- --allATTENTION: This will change the commit hash and name - you may not want to do this if others have already used this.
git push --forcegerman: Anmeldeinformationsverwaltung english: Credential Manager
one of your users can use the Windows Credential Manager for the target "git:https://github.com/" but for me this never worked IRL
[credential]
helper = wincred
Sometimes on a Windows PC, there are already credentials for Git, and they may be problematic.
Install-Module -Name CredentialManager$credentials = Get-StoredCredential -Target "git:https://github.com/"
Export-Clixml -InputObject $credentials -Path "C:\Path\to\YourBackup.xml"ATTENTION: keep this YourBackup.xml as private as your password
$credentials = Import-Clixml -Path "C:\Path\to\YourBackup.xml"
New-StoredCredential -Target $credentials.Target -UserName $credentials.UserName -SecurePassword $credentials.Password -Persist LocalMachineRemove-StoredCredential -Target "git:https://github.com/"