Pull Github Template Changes to local repository

This week I have been working on a repository at work that has been forked from another 'template' repo.

As such when changes are made to this template repository, I needed a way to pull those changes back down to my repo.

Luckily my boss at work had some nice step-by-step instructions that I would like to share on here so I never forget them.

  1. Add the original template repository as a remote for your current project repository
$git remote add template [URL of the template repo]

2. You can then run 'git fetch' which will return all the repositories updated references.

$git fetch --all

You now have the connections on your current repository to pull in the updated changes.

3. you can now use the 'template/' keyword when doing a 'git merge'. You will need to make sure you enter the name of the branch you want to merge as well.

$git merge template/[branch to merge]
โš ๏ธ
fatal: refusing to merge unrelated histories

If during step 3 you come across the above error message. Do not worry, this is expected behaviour. To fix this you need to just add --allow-unrelated-histories to the step 3 command.

$git merge template/[branch to merge] --allow-unrelated-histories

And your done. All that is left is to check and resolve any conflicts that have occurred and push your new code back into your repository.

My boss who had these step by steps saved has a great repository online that has a ton of docker images for all tech stacks. So if you liked this post, head over and star his repository.

GitHub - luisaveiro/playground: Docker Compose collection of tech stack samples.
Docker Compose collection of tech stack samples. Contribute to luisaveiro/playground development by creating an account on GitHub.

Subscribe to Making sense of the world around me, one blog post at a time

Donโ€™t miss out on the latest issues. Sign up now to get access to the library of members-only issues.
jamie@example.com
Subscribe