【问题标题】:Is it possible to create patch using format-patch from another server?是否可以使用来自另一台服务器的格式补丁创建补丁?
【发布时间】:2018-12-10 21:13:13
【问题描述】:

来自this所以回答:

$ git --git-dir=../<some_other_repo>/.git \
format-patch -k -1 --stdout <commit SHA> | \
git am -3 -k

是否可以跨服务器做同样的事情?换句话说,如果 git-dir 在不同的物理服务器中,是否可以使用类似:--git-dir=otherServerName:/path/to/repo/.git

【问题讨论】:

    标签: git


    【解决方案1】:

    一种可能的解决方案是将服务器添加为远程:

    $ git remote add <remote-name> <remote-uri>
    

    然后获取更改:

    $ git fetch <remote-name>
    

    现在您可以直接在您的机器上提交,而无需修改任何本地分支。您可以在没有--get-dir 选项的情况下按照您的问题创建补丁。如果您希望提交当前工作,您可以使用git cherry-pick 或任何其他直接使用 SHA 哈希的适当 git 命令。

    【讨论】:

      【解决方案2】:

      git 方式是将服务器临时添加为 remote 存储库并 cherry-pick 提交。

      git remote add <name> <url>
      git fetch <name>
      git cherry-pick <commit SHA>
      git remote remove <name>
      

      例如,如果 repo 在 GitHub 或 GitLab 上,您可以执行以下操作:

      curl https://github.com/<user>/<repo>/commit/<commit SHA>.patch | \
      git am -3 -k
      

      检查你的 git 服务器的 API 文档。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2023-03-09
        • 1970-01-01
        • 2015-02-12
        • 2010-09-08
        • 2015-05-21
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多