git 子模块"you need to resolve your current index first"但没有合并冲突



我遇到了一个无法解决的奇怪问题。詹金斯正在一个仓库里建造。

它检查应用程序的当前提交(这是正确的(,然后初始化子模块(也是正确的,并找到正确的提交(。

但当它尝试执行git submodule update --init --recursive repo时,它会放弃:

app/views/license/edit.html:需要合并

问题是没有冲突,并且当前提交源中的文件非常好。。。

我只是不知道从这里到哪里去。

> git rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
> git config remote.origin.url git@bitbucket.org:TEAM/api-backend.git # timeout=10
Fetching upstream changes from git@bitbucket.org:TEAM/api-backend.git
> git --version # timeout=10
using GIT_SSH to set credentials
> git fetch --tags --progress git@bitbucket.org:TEAM/api-backend.git +refs/heads/*:refs/remotes/origin/*
> git rev-parse refs/remotes/origin/dev^{commit} # timeout=10
> git rev-parse refs/remotes/origin/refs/heads/dev^{commit} # timeout=10
Checking out Revision 99ab7742966fd82f21044e7bf5f405eaf3bd085b (refs/remotes/origin/dev)
> git config core.sparsecheckout # timeout=10
> git checkout -f 99ab7742966fd82f21044e7bf5f405eaf3bd085b
Commit message: "Front-end update"
> git rev-list --no-walk 99ab7742966fd82f21044e7bf5f405eaf3bd085b # timeout=10
> git remote # timeout=10
> git submodule init # timeout=10
> git submodule sync # timeout=10
> git config --get remote.origin.url # timeout=10
> git submodule init # timeout=10
> git config -f .gitmodules --get-regexp ^submodule.(.+).url # timeout=10
> git config --get submodule.compose/web.url # timeout=10
> git config -f .gitmodules --get submodule.compose/web.path # timeout=10
> git submodule update --init --recursive compose/web
hudson.plugins.git.GitException: Command "git submodule update --init --recursive compose/web" returned status code 1:
stdout: app/views/license/edit.html: needs merge
stderr: error: you need to resolve your current index first
Unable to checkout '71e9f5f5d30ec8b2bcd7d341e4b607ab123a4ece' in submodule path 'compose/web'

我尝试了对有问题的文件进行一些更改的伪提交,并将其合并到dev-to-branch,但这并没有解决问题…

让我困惑的是,为什么它不告诉我合并时存在冲突?

进一步测试

我对父存储库进行了新的克隆,并运行了git submodule --init --recursive compose/web。它成功地克隆并检出了右分支。。。

所以我甚至无法在本地复制。

我该怎么修?

我从一条完全不同的路径到达这个位置。我试图从一次糟糕的合并中解脱出来,打碎了当地的一棵树。我不知道这是由于git中的错误还是其他途径造成的,但我先运行了git merge --quit,然后运行了git switch master(当前工作区是一个分离的头,因此不需要将其恢复到正常状态(。树被破坏了,因为它有一个合并冲突的文件,但没有进行合并。

Krishnamoorthy Acharya被删除的答案包含了如何挽救它的基本形式,更新如下:

git reset
git restore .
git switch master

git reset之后,合并冲突文件更改为已编辑,然后git restore .放弃了所有挂起的更改,所以git switch很高兴。

如前所述,问题发生在Jenkins工作区级别。

如果作业是从头开始重建的(空工作区(,那么问题就会消失。

关于错误,

错误:您需要首先解决当前索引的

git reset --merge or git merge --abort如果您已经接受了对文件的当前或传入更改,则不会工作。只需遵循以下步骤:

  1. git add "fileName"-您接受更改的文件
  2. git commit -m "your commit msg"

现在您可以签出或合并其他分支。

我在Jenkins中遇到了同样的问题。我克隆了一个管道,收到了同样的错误。尝试删除C:\Program Files(x86(\Jenkins\workspace中与管道相关的工作区,然后在Jenkins中重新构建项目。

看起来您有合并冲突。尝试:

git mergetool app/views/license/edit.html

最新更新