Pushing to Multiple Git Repos
Let’s say you have sourcehut as your
primary git location, but also want to push that same repo to a
github instance without having a mirror setup. What you can do
is configure the two additional remotes and push them from there.
All one needs is the following:
$ git remote set-url --add --push origin firstname.lastname@example.org:~USER/REPO.git $ git remote set-url --add --push github email@example.com:USER/REPO.git
If you take a look at your
config file under your
the added urls will appear under:
[remote "origin"] url = firstname.lastname@example.org:~USER/REPO fetch = +refs/heads/*:refs/remotes/origin/* pushurl = email@example.com:~USER/REPO [remote "github"] url = firstname.lastname@example.org:USER/REPO.git fetch = +refs/heads/*:refs/remotes/github/* pushurl = email@example.com:USER/REPO.git
The only thing left to do now, is code, commit, push to each of the respective repos and they will be updated. For example:
git push # that will default to pushing to your origin repo git push github # self-explanatory
You can write a script if you want to automate or not forget pushing to both repos at the same time.