【问题标题】:Changes in files on GitHub will also do change in GitLab filesGitHub 上文件的更改也会对 GitLab 文件进行更改
【发布时间】:2022-01-04 06:33:39
【问题描述】:

我在 GitHub 上有多个存储库,现在我将它们转移到 GitLab。

我的开发人员在 GitHub 文件上提交更改。

现在,有什么解决方案可以使在 GitHub 上提交的更改也会更改 GitLab 上的文件?

【问题讨论】:

标签: git github gitlab github-actions


【解决方案1】:

如果在“转移”时,这些存储库从本地 GitHub 副本推送到 GitLab,则它们共享一个共同的历史记录。

这意味着,从本地 GitLab 克隆中,您可以:

  • 将旧的 GitHub URL 添加为远程地址
  • 从 GitHub 获取
  • 将获取的分支合并到您的 GitLab 分支
  • 推送到您的正常源远程(GitLab URL)
cd /path/to/GitLab/local/clone
git remote add github https://github.com/old/project
git fetch github
git merge github/main
git push

正如评论的那样,另一种方法是让您的开发人员发送到push both to GitHub and GitLab,假设该开发人员是唯一一个在两个存储库中的当前分支上工作的人(或者它在向两个存储库进行任何推送之前开始涉及复杂的同步步骤)

# For developer working on GitHub
cd /path/to/GitHub/local/clone
git remote set-url origin --push --add https://github.com/old/project
git remote set-url origin --push --add https://gitlab.com/new/project
# work: add and commit
git push

【讨论】:

    猜你喜欢
    • 2018-07-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-08-24
    • 2020-07-09
    • 2021-05-15
    • 2012-10-02
    • 2020-11-13
    相关资源
    最近更新 更多