You started a project from a template repository but the template changed since you started the project? Template Sync will import the changes made to the template to your project in a blink!
curl -sSL https://raw.githubusercontent.com/coopTilleuls/template-sync/main/template-sync.sh | sh -s -- <url-of-the-template>
If you have some conflicts, resolve them and run git cherry-pick --continue
.
This script identifies a commit in the template history which is the closest one to your project. Then it squashes all the updates into a commit which will be cherry-picked on the top of your working branch. Therefore you just have to resolve conflicts and work is done!
Using this kind of templates, you have to specify the subdirectory where your template is with
the --directory
flag.
For example, assume you work on a project base on the template "api-routes" from next starters. The main monorepo is vercel/next.js and the template is located in examples/api-routes :
curl -sSL https://raw.githubusercontent.com/coopTilleuls/template-sync/main/template-sync.sh | sh -s -- https://github.com/vercel/next.js --directory=examples/api-routes
-
Go to your project repository (we recommend to create a new branch) Copy template-sync.sh at the root of your project
-
The only mandatory argument is the GitHub or GitLab URL of your template but if you want to synchronize your project with a specific version of the template, you can specify the commit you are targeting by adding
--commit=<commit SHA>
. E.g. Assume your project is based on dunglas/symfony-docker and you just want to get the improvements of the new php app server FrankenPHP. Run this command :
curl -sSL https://raw.githubusercontent.com/coopTilleuls/template-sync/main/template-sync.sh | sh -s -- https://github.com/dunglas/symfony-docker --commit=88f5c19
- In case some files are renamed or moved in the template history, you can modify the threshold where git considers two files as identical. Default value for this script is 20% (git's default value is 50%). If git is confused and considers files that are not identical to be identical, you can raise this threshold. E.g:
curl -sSL https://raw.githubusercontent.com/coopTilleuls/template-sync/main/template-sync.sh | sh -s -- <url-of-the-template> --threshold=30
-
You can run the script in debug mode by adding the
--debug
flag. -
If for any reason you are not satisfied with the result of the script you just have to run
git cherry-pick --abort
to rollback before the execution of the script.
Created by Emmanuel Barat and Raphael Marchese