running git clone in node with execSync deletes some files

Viewed 146

In a node server, I am currently attempting to pull down a remote repo with the native child_process.execSync method. I tested the command to be executed from the command line for sanity testing first:

git clone -b <branch-name> --single-branch https://<token>@<repo>

Which pulls down the specific branch of the target repo with no further authentication needed.

The execSync code looks like this:

execSync(
    "<git clone command from above>",
    {
        stdio: [0, 1, 2],
        cwd: path.resolve(___dirname, ""),
    }
)

Which clones the target repo also as intended with no further outputs. However an entire folder src is missing from the cloned repo, and running git status in the cloned directory shows that every file in src was deleted as an uncommitted change.

The entire reason I'm cloning the repo in this way is to access/manipulate some files in that directory, so this is an issue. Does anybody have any ideas as to what could be happening under the hood to cause this issue and how it can be fixed?

I have seen other SO posts mentioning similar problems when running git clone (not in a child process) and having files deleted, but they seem to be related to reserved keyword issues for Windows (I am on Windows, but there are no keyword conflicts with any of the deleted files) or with core.longpaths in my git config since some of the paths are fairly long, but making sure that boolean is flipped to true in my config doesn't fix the issue either.

0 Answers
Related