git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: bug report: cloning private repo to absolute path doesn't work if gitconfig has includeIf directives

From
brian m. carlson <sandals@crustytoothpaste.net>
Date
Jul 13, 2023, 00:21 UTC
Message-ID
<ZK9Dgqgy5qRDKhG0@tapette.crustytoothpaste.net>
In-Reply-To
<CADfPAEbgfvnS6JTwa5Y1Zt7gQ31GRUyjjjpX9mmpcwxsaTLPGw@mail.gmail.com>
On 2023-07-12 at 16:21:38, Juan M Uys wrote:
Show 24 quoted lines
> What happened instead? (Actual behavior)
> 
> ```
> % git clone --depth=1 'git@github.com:myorg/myprivaterepo.git' '/tmp/some-new-folder'
> Cloning into '/tmp/some-new-folder'...
> ERROR: Repository not found.
> fatal: Could not read from remote repository.
> 
> Please make sure you have the correct access rights
> and the repository exists.
> ```
> 
> However, if I remove the last argument, it works, and clones to the current directory:
> 
> ```
> % git clone --depth=1 'git@github.com:myorg/myprivaterepo.git'
> Cloning into 'myprivaterepo'...
> remote: Enumerating objects: 99, done.
> remote: Counting objects: 100% (99/99), done.
> remote: Compressing objects: 100% (87/87), done.
> remote: Total 99 (delta 7), reused 77 (delta 7), pack-reused 0
> Receiving objects: 100% (99/99), 5.66 MiB | 4.71 MiB/s, done.
> Resolving deltas: 100% (7/7), done.
> ```

Is the directory you're cloning to the same as above? Do you see the same behaviour as above if you switch to /tmp and run this:

  $ git clone --depth=1 'git@github.com:myorg/myprivaterepo.git' some-new-folder
Show 35 quoted lines
> I separate my git organisations with different SSH keys with the help of a global git config:
> 
> ```
> init]
>         defaultBranch = main
> [user]
>         email = opyate@gmail.com
>         name = Juan Uys
> [core]
>         excludesfile = /home/opyate/.gitignore
>         editor = vim
>         pager = less -FRX
> 
> [includeIf "gitdir:/home/opyate/Documents/code/org1/"]
>         path = /home/opyate/Documents/code/org1/gitconfig
> [includeIf "gitdir:/home/opyate/Documents/code/org2/"]
>         path = /home/opyate/Documents/code/org2/gitconfig
> [filter "lfs"]
>         clean = git-lfs clean -- %f
>         smudge = git-lfs smudge -- %f
>         process = git-lfs filter-process
>         required = true
> ```
> 
> And then each org's gitconfig typically looks like:
> 
> ```
> [user]
>         name = Juan Uys
>         email = juan.uys@org1.com
> 
> 
> [core]
>         sshCommand = "ssh -i ~/.ssh/org1/id_ed25519"
> ```

My guess is that this is related. If you're cloning into one of the directories specified with `includeIf` above, then you'd be using a specific SSH key to do so. In such a case, you'd have access to different things than if you cloned in a different repository.

That would explain why public repositories work: as long as you have an SSH key valid for _some_ account on GitHub, you can clone any public repository.

-- 
brian m. carlson (he/him or they/them)
Toronto, Ontario, CA
Previous: Juan M Uys
Message 2 of 2 in “bug report: cloning private repo to absolute path doesn't work if gitconfig has includeIf directives”
  1. Juan M UysJul 12, 2023
  2. brian m. carlsonJul 13, 2023

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.