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 +} +```