GitHub - Pull changes from a template repository

I will link to the same location as HRK44 but my answer is very different.

https://help.github.com/en/articles/creating-a-repository-from-a-template

Although forks and templates are mentioned in the same section, they are very different.

One of the differences mentioned in the link is:

A new fork includes the entire commit history of the parent repository, while a repository created from a template starts with a single commit.

This basicly means that you will not be able to pull new changes from the template as your git histories are very different and are not based on the same thing.

If you do use the method mentioned in the accepted answer, you will have very hard manual merges that will result in changes to all of the files received from the template, even if they werent changed since the first time you created that repo from that template.

In short, creating a repo from a template (using only master branch) is the same process as:

git clone template
cd folder
rm -rf .git
git init
git remote add origin <new repo url>
git add . 
git commit -m "Initial Commit"
git push -u origin master

A few other things that are not (surprisingly) copied when creating a repo from a template: (Unless github fix this at a later point)

  1. Repo configurations (allowed merge types, permissions etc)
  2. branch rules

So when using this at your organization, make sure to set all repo configurations on the newly created repo.


On the other repositories you have to add this template repository as a remote.

git remote add template [URL of the template repo]

Then run git fetch to update the changes

git fetch --all

Then is possible to merge another branch from the new remote to your current one.

git merge template/[branch to merge]

https://help.github.com/en/articles/adding-a-remote

Tags:

Github