Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions .husky/post-checkout
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down Expand Up @@ -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鈥檚 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鈥檚 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
Expand Down
Loading