From ef2a56594f65d33d11e3ba47d3c91470566327e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=82=A2=E3=83=AC=E3=82=AF=E3=82=B5=E3=83=B3=E3=83=80?= =?UTF-8?q?=E3=83=BC=2Eeth?= <4975670+0x4007@users.noreply.github.com> Date: Fri, 19 Jul 2024 14:35:14 +0900 Subject: [PATCH] Update README.md --- README.md | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/README.md b/README.md index 7b0867a..4bb0e6a 100644 --- a/README.md +++ b/README.md @@ -30,3 +30,41 @@ To start Jest tests, run ```shell yarn test ``` + +## Sync any repository to latest `ts-template` + +A bash function that can do this for you: + +```bash +sync-branch-to-template() { + local branch_name + branch_name=$(git rev-parse --abbrev-ref HEAD) + local original_remote + original_remote=$(git remote show | head -n 1) + + # Add the template remote + git remote add template https://github.com/ubiquity/ts-template + + # Fetch from the template remote + git fetch template development + + if [ "$branch_name" != "HEAD" ]; then + # Create a new branch and switch to it + git checkout -b "chore/merge-${branch_name}-template" + + # Merge the changes from the template remote + git merge template/development --allow-unrelated-histories + + # Switch back to the original branch + git checkout "$branch_name" + + # Push the changes to the original remote + git push "$original_remote" HEAD:"$branch_name" + else + echo "You are in a detached HEAD state. Please checkout a branch first." + fi + + # Remove the template remote + # git remote remove template +} +```