When the git clone
code creates the new (empty) repository, it uses the init_db
function, which ends with a block including this code:
/* Check if symlink is supported in the work tree */
path = git_path_buf(&buf, "tXXXXXX");
if (!close(xmkstemp(path)) &&
!unlink(path) &&
!symlink("testing", path) &&
!lstat(path, &st1) &&
S_ISLNK(st1.st_mode))
unlink(path); /* good */
else
git_config_set("core.symlinks", "false");
Since you are getting an explicit core.symlinks = false
, this line must be overriding your request to set core.symlinks = true
. Note that the setting depends on the actual OS support, rather than any command line option. However, if you move the work-tree elsewhere later, the explicit setting remains in the .git/config
file.
Meanwhile, there are two other issues. One is what ElpieKay mentioned in a comment: For most commands, you can temporarily override the configuration using git -c name=value subcommand
, which would be git -c core.symlinks=true clone arguments
. This is worth trying, in case your particular Git version is out of date and does not match the code I am quoting and linking-to here.
However, git clone
is quite special: it's essentially an optional mkdir
to create the repository and work-tree directories, followed by a git init
, followed by some configuration setting, followed by a git fetch
and a git checkout
. So this means you can use git -c name=value clone -c name=value ...
. The first name=value
setting is in use while the repository gets created, i.e., during git init
. The second name=value
is the one that git clone
drops into the new clone, using this bit of code:
init_db(git_dir, real_git_dir, option_template, INIT_DB_QUIET);
if (real_git_dir)
git_dir = real_git_dir;
write_config(&option_config);
git_config(git_default_config, NULL);
The write_config
function is where Git writes your core.symlinks=true
from your git clone -c core.symlinks=true ...
command. So this in theory should override the core.symlinks=false
setting that init_db
computed. This is the part I find curious: that it doesn't.
The subsequent git_config
call reads the actual config written into the new repository's .git/config
. This will set the internal has_symlinks
variable, which will control the internal git checkout
that git clone
runs. So if this did override the init_db
setting, everything would work just the way you want. What's not obvious is why it doesn't override. The code here is a bit twisty, but it seems like your command-line option should override the init_db
setting.
(Of course, if symlinks actually work in the work-tree, the init_db
code should not be setting core.symlinks=false
in the first place!)
git -c core.symlinks=true clone --recurse-submodules -b develop [email protected]/my-project.git
.-c name=value
should be betweengit
and the sub-command. – Stpierre