diff --git a/.husky/post-checkout b/.husky/post-checkout index 88fd40e..332fa3d 100644 --- a/.husky/post-checkout +++ b/.husky/post-checkout @@ -2,8 +2,13 @@ # .git/hooks/post-checkout # Check if template remote exists -if ! git remote | grep -q "^template$"; then - git remote add template https://github.com/peerigon/template.git +if ! git remote get-url template >/dev/null 2>&1; then + # Use the same protocol as origin (SSH or HTTPS) + case "$(git remote get-url origin 2>/dev/null)" in + ssh://*|*@*:*) template_url=git@github.com:peerigon/template.git ;; + *) template_url=https://github.com/peerigon/template.git ;; + esac + git remote add template "$template_url" fi git remote set-url --push template DISABLED diff --git a/README.md b/README.md index c1200c7..cf2c80b 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ #### Step 1: -Fork this repository. This way the new repository will reference this repository as `template` and you will be able to easily pull in updates from this repository. +Fork this repository. This way the new repository will reference this repository as `template` and you will be able to easily pull in updates from this repository. The checkout hook matches `origin`'s HTTPS/SSH protocol and preserves existing `template` URLs. #### Step 2: @@ -113,7 +113,7 @@ Before starting the merge, collect information about the existing project: ## Phase 2: Execute Git Merge -Add the template as `template` and **disable pushes** to it (so you never send your project’s commits to the public template). If `template` already exists, only run the `set-url --push` line. +Add the template as `template` and **disable pushes** to it (so you never send your project’s commits to the public template). If `template` already exists, only run the `set-url --push` line. For SSH, use `git@github.com:peerigon/template.git` instead. ```bash git remote add template https://github.com/peerigon/template.git