Warum mehrere Remotes
Reale Workflows beinhalten oft mehr als ein Remote: ein origin fur Ihren Fork, ein upstream fur das kanonische Repo, plus Mirror, Deploy-Ziele und Forks pro Umgebung.
Remotes hinzufugen
git remote add origin [email protected]:you/fork.git
git remote add upstream https://github.com/org/repo.git
git remote add deploy [email protected]:app.git
git remote -v
Von allen abrufen
git fetch --all --prune
git remote update --prune
git fetch upstream main:main
Das Richtige tracken
git branch --set-upstream-to=origin/main main
git push -u origin feature
git config branch.feature.remote origin
git config branch.feature.merge refs/heads/feature
Verschiedene Push- und Pull-URLs
git remote set-url --push origin [email protected]:you/fork.git
git remote set-url origin https://github.com/you/fork.git
Mirroring
git remote add mirror --mirror=push [email protected]:org/repo.git
git push mirror
Triangularer Workflow
git config remote.pushDefault origin
git config push.default current
Anmeldedaten pro Remote
[credential "https://github.com"]
helper = osxkeychain
[credential "https://gitlab.example.com"]
helper = !pass-git-helper
Haufige Fehler
Versehentlich zu upstream pushen, wenn origin gemeint war.