【问题标题】:Is it possible to clone a repo within a repo and commit to just to the inner repo?是否可以在仓库中克隆仓库并只提交到内部仓库?
【发布时间】:2021-09-03 08:27:47
【问题描述】:

我在 typescript、react、node.js 和 express 工作。在我的节点服务器中,我调用 execSync 来克隆另一个 repo,向其中添加文件,然后推送这些更改。类似这样的东西:

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>);

但是,推送部分总是失败。经过进一步检查,我发现这段代码在 outer repo 而不是 inner repo 中创建了分支。

任何有关实现此功能的建议或提示将不胜感激。如果有更清洁的方法来实现这一点,我也将不胜感激。

注意:两个 repos 都托管在 gitlab 上。

【问题讨论】:

标签: node.js typescript git gitlab exec


【解决方案1】:

是的。

最里面的 repo 将作为它自己的 repo。为了安全起见,我会要求您在外部仓库的.gitignore 文件中添加最里面的仓库,这样您就不会意外添加带有git add . 的内部仓库(目录)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2023-03-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-06-12
    • 1970-01-01
    • 2014-02-26
    相关资源
    最近更新 更多