Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
0x4007 authored Jul 19, 2024
1 parent 997e61b commit ef2a565
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
```

0 comments on commit ef2a565

Please sign in to comment.