0

I'm working in typescript, react, node.js and express. In my node server I am calling execSync to clone another repo, add files to it, and then push those changes. Something along the lines of this:

execSync("git clone <sub-repo> <path-to-sub-repo> \
    && cd <path-to-sub-repo> \
    && git checkout -b <branch-name>");

alterSubRepoFiles(<path-to-sub-repo-file>, content);

execSync("cd <path-to-sub-repo> \
    && git add . \
    && git commit -m \"some message here\" \
    && git push --set-upstream origin <branch-name>);

However, the push part always fails. Upon further inspection I found that this code was making branches in the outer repo instead of the inner repo.

Any advice or tips on a way achieve this functionality would be much appreciated. If there is a cleaner way to achieve this I would also appreciate the advice.

Note: Both repos are hosted on gitlab.

Svigg
  • 21
  • 1
  • [https://stackoverflow.com/questions/1871282/nested-git-repositories](https://stackoverflow.com/questions/1871282/nested-git-repositories) – lbsn Jun 18 '21 at 16:00

1 Answers1

0

Yes, it is.

The inner most repo will function as its own repo. Just to be on the safer side, I'd ask you to add the innermost repo in .gitignore file of your outer repo so that you don't accidentally end up adding the inner repo (directory) with a git add .

rish.uk
  • 93
  • 8