May 1, 2021

Add multiple remotes to one git repository and use one as a template

I must admit I'm kind of a noob when it comes to Git. I have worked more or less on my own for the last 10 years and I have never really got involved in the open source world. So i have mainly used git as kind of a source code backup system.

But sometimes i want to do some more advanced stuff (well, advanced and advanced, things i don't know how to do). This time i wanted to have a repository as a template for a few blogs, this one and one for a AlternativeTo blog and maybe some more in the future. My thinking was that if i create a template with minimal config i could use that as a main repository and take care of package updates and global changes in that repository and then pull these changes into the actual blog repositories.

I thought i needed some kind of special setup with forks and so on but it turns out i could just add multiple remotes. This assumes that you already have two repositories. You can set the template repository as a "template" on Github as well if you use github and you want new sites based on the template not to share history and so on.

Add the remote for the template repository to the "alt2-dev-blog"

git remote add template https://github.com/me/alt2-blog-template.git

Then i could pull from that remote and and everything in it will be merged into 'alt2-dev-blog'.

git pull template master

And then push to that just as usual

git push origin

Now I have a repository with two remotes and i can just pull and merge changes from the template repository into my actual blog repository.

This is maybe super obvious for a pro git user but i have never experimented with multiple remotes and i guess i'm still not really used to the "distributed nature" of git.

© Copyright 2021 AlternativeTo . Powered with by CreativeDesignsGuru