gpt4 book ai didi

git-tfs - 当 git tfs 无法创建合并提交时,如何更正

转载 作者:行者123 更新时间:2023-12-01 03:50:57 25 4
gpt4 key购买 nike

当 git tfs 无法创建合并提交时,它说warning: this changeset 7504 is a merge changeset. But it can't have been managed accordingly because one of the parent changeset 7494 is not present in the repository! If you want to do it, fetch the branch containing this changeset before retrying...
根据 documentation , Note: if you see a warning, you could correct that by reseting the tfs remote to a previous commit. Then fetch the merged branch and retry to fetch the branch.
任何人都可以详细说明reseting the tfs remote to a previous commit .虽然,我现在已经获取了合并的分支,但我不明白如何将其重置为之前对失败分支的提交。我不确定,但我必须git checkout <hash of the previous commit> ?

最佳答案

是的,现在 git-tfs 尝试在遇到合并变更集时创建合并提交(现在它具有令人满意的分支支持)。

此消息只是一条警告消息,当您看到它时,您有 2 个选项...

  • 第一个是什么都不做,因为你知道,例如,它是一个旧的功能分支,你永远不会在它上面工作,更重要的是,将来你永远不会再在你的父分支中合并。
  • 第二个是如果你真的想要这个合并提交。因为你想要一个好的历史或更重要的,因为你仍然在这个分支上工作并且必须将它合并到父分支中。

  • 为此,您必须重置 tfs 远程(因为实际上已经创建了提交——以保持与 git-tfs 在以前版本中的工作方式以及那些不能使用分支的版本兼容——)。

    要重置 Remote ,您必须使用 reset-remote命令。

    然后用 branch --init 初始化在父分支中合并的分支.

    还将本地分支重置到 tfs 远程(由于内部 git-tfs 优化)。

    并再次获取父分支。现在合并的分支存在并且正在获取,git-tfs 将从合并的分支中找到父变更集,并且您的 git 存储库中将有一个漂亮的合并提交;)

    所以,如果你早点这样做
    git tfs clone https://CompanyName.visualstudio.com/DefaultCollection "$/CompanyName/Main" KfGitMain --workspace="C:\TFS\Main"
    cd GitMain
    git tfs branch --init "$/CompanyName/Release/20140121.1" live20140121.1
    git tfs branch --init "$/CompanyName/Release/20140121.1-hotfix" hotfix20140121.1

    如果您因代码相互合并而收到所有三个警告,那么您将不得不
    git checkout hotfix
    git tfs reset-remote 5fb83335b8dfc6fbb96e0a54a48dc06c506e3277 ## previous commit of the first failed commit
    git reset --hard tfs/hotfix
    git tfs pull -i hotfix

    git checkout live
    git tfs reset-remote eba62a1446f3f81676d051336ca254fe54c37d74
    git reset --hard tfs/live
    git tfs pull -i live

    git checkout master
    git tfs reset-remote 72727737ec52f9b96d22d343770186a342c8b166
    git reset --hard tfs/default
    git tfs pull -i default

    注意:如果你没有太多的分支和/或奇怪的 tfs 历史,所有这些都可以使用 git clone 来避免。带有选项 --with-branches这将初始化并获取所有处理合并变更集的分支

    关于git-tfs - 当 git tfs 无法创建合并提交时,如何更正,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22854457/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com