Wann Sie sich losen wollen
Sie haben ein Repo geforkt, Ihre Arbeit gepusht und wollen jetzt unabhangig veroffentlichen.
Remotes auflisten
git remote -v
Ein Remote entfernen
git remote remove origin
git remote -v
Ein neues origin hinzufugen
git remote add origin [email protected]:yourname/project.git
git push -u origin --all
git push -u origin --tags
Stattdessen umbenennen
git remote rename origin upstream
git remote add origin [email protected]:yourname/project.git
git fetch --all
git remote -v
Eine Remote-URL aktualisieren ohne entfernen
git remote set-url origin [email protected]:team/project.git
git remote set-url --push origin [email protected]:team/project.git
Tracking-Refs nach Loslosung entfernen
git for-each-ref refs/remotes/origin --format='%(refname)' | \
xargs -n 1 git update-ref -d
Vollstandig vom Upstream losen
# Option 1: keep history but rewrite the parent
git checkout --orphan new-main
git add -A
git commit -m "Initial commit (rebased history)"
# Option 2: keep history, just publish to a new remote
git remote remove origin
git remote add origin <new-url>
git push -u origin --all
Zu mehreren Remotes pushen
git remote set-url --add --push origin [email protected]:user/repo.git
git remote set-url --add --push origin [email protected]:user/repo.git
git push origin main
Im Nachhinein prufen
git config --get-regexp '^remote\\.'
git remote show origin
Haufige Fallstricke
- Vergessen, Tags auf das neue Remote zu pushen.
- CI-Konfiguration nicht aktualisieren.
- Submodule auf altes Remote zeigend.