question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Global init.templatedir setting ignored when cloning repositories

See original GitHub issue

Describe the bug

The templatedir configuration appears to be ignored by Desktop when cloning a repository.

Version & OS

Version 2.2.4 macOS 10.15.2 (19C57)

Steps to reproduce the behavior

  1. Create a directory with template hooks
  mkdir -p /var/tmp/testtemplatedir/hooks
  echo "#!/usr/bin/env bash" > /var/tmp/testtemplatedir/hooks/post-checkout
  echo  "echo hi" >> /var/tmp/testtemplatedir/hooks/post-checkout
  chmod +x /var/tmp/testtemplatedir/hooks/post-checkout
  1. Configure template directory git config --global init.templatedir /var/tmp/testtemplatedir/hooks/post-checkout
  2. Open Desktop and clone any repository (e.g., https://github.com/desktop/desktop.git)
  3. Examine the .git/hooks directory inside of the newly cloned repository

Expected behavior

The post-checkout hook should be present in the clone

Actual behavior

The repository only contains the default sample hooks and does not contain the post-checkout hook

Additional context

Cloning the same repo via the git CLI (version 2.24.1) properly utilizes the template dir.

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:1
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
abairecommented, Jan 28, 2020

Minimal log in case it helps

2020-01-28T18:53:24.562Z - info: [ui] [AppStore] loading 3 repositories from store
2020-01-28T18:53:24.563Z - info: [ui] [AppStore] found account: abaire (Erik Abair)
2020-01-28T18:53:24.645Z - info: [ui] [BranchPruner] Last prune took place in a day - skipping
2020-01-28T18:53:24.909Z - info: [ui] Current tutorial step is NotApplicable
2020-01-28T18:53:24.960Z - info: [ui] launching: 2.2.4 (Mac OS 10.15.2)
2020-01-28T18:53:24.960Z - info: [ui] execPath: '/Applications/GitHub Desktop.app/Contents/Frameworks/GitHub Desktop Helper.app/Contents/MacOS/GitHub Desktop Helper'
2020-01-28T18:53:25.052Z - info: [ui] Current tutorial step is NotApplicable
2020-01-28T18:53:29.755Z - info: [ui] Current tutorial step is NotApplicable
2020-01-28T18:53:32.378Z - info: [ui] Current tutorial step is NotApplicable
2020-01-28T18:53:41.307Z - info: [ui] [AppStore.getAccountForRemoteURL] account found for remote: https://github.com/desktop/desktop.git - abaire (has token)
2020-01-28T18:54:19.461Z - info: [ui] Executing clone: git -c credential.helper= -c protocol.version=2 clone --recursive --progress -- https://github.com/desktop/desktop.git /**A_PATH_TO_A_VALID_DIR**/desktop2 (took 38.133s)
2020-01-28T18:54:19.469Z - info: [ui] [AppStore] adding repository at /**A_PATH_TO_A_VALID_DIR**/desktop2 to store
2020-01-28T18:54:19.626Z - info: [ui] [BranchPruner] No branches to prune.
2020-01-28T18:54:19.627Z - info: [ui] [BranchPruner] Last prune took place in a day - skipping
2020-01-28T18:54:20.578Z - info: [ui] Current tutorial step is NotApplicable
2020-01-28T18:54:20.918Z - info: [ui] Executing getStatus: git --no-optional-locks status --untracked-files=all --branch --porcelain=2 -z (took 1.335s)
2020-01-28T18:54:20.983Z - info: [ui] Current tutorial step is NotApplicable
1reaction
lee-dohmcommented, Jan 28, 2020

I was able to replicate this using Desktop v2.2.4 and git v2.25.0 on macOS 10.15.2. Here’s what I did:

  1. Create a template directory with the contents described above
  2. Configure the template directory using git config --global init.templateDir
  3. Created a new git repository using git init
  4. Verified that the .git/hooks directory contained only the one file post-checkout with the contents expected
  5. Cloned a git repository using git clone
  6. Verified that the .git/hooks directory contained only the one file post-checkout with the contents expected. Additionally, I saw the hi message at the end of the clone process
  7. Created a new local git repository using Desktop by:
    1. Click “Current Repository” drop down
    2. Click “Add …” button
    3. Select “Create New Repository…” from the context menu
  8. Verified that the .git/hooks directory did not contain the expected post-checkout file but did contain the standard git sample hooks
  9. Cloned a new local git repository using Desktop by:
    1. Click “Current Repository” drop down
    2. Click “Add…” button
    3. Select “Clone Repository…” from the context menu
  10. Verified that the .git/hooks directory did not contain the expected post-checkout file but did contain the standard git sample hooks
Read more comments on GitHub >

github_iconTop Results From Across the Web

Git doesn't clone content of template directory - Stack Overflow
I'm doing the git config init.templatedir on the server, because I thought the templatedir was cloned to the local .git directory..... I think...
Read more >
git-init Documentation - Git
This command creates an empty Git repository - basically a .git directory with subdirectories for objects , refs/heads , refs/tags , and template...
Read more >
Change git init default branch name - Super User
git config --global init.defaultBranch main. After setting this variable, running git init will produce a repository whose initial branch is ...
Read more >
Upgrading from 2.xx to 3.xx - Git Template
It means each time you create a new repository, and each time you clone a repository, ... git config --global init.templatedir '~/.git_template/template'.
Read more >
Setting up a Git Repository - Visual Studio for Mac
In this article. Creating a remote repo on GitHub; Clone an existing repository. Applies to: yes Visual Studio for Mac no Visual Studio....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found