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.