致命:无法创建'/home/circleci/project/.git/index.lock':文件存在

问题描述 投票:0回答:1

我正在工作流中运行一个步骤,该步骤在CircleCI内置git checkout branchname步骤之后立即执行- checkout,并且出现以下错误:fatal: Unable to create '/home/circleci/project/.git/index.lock': File exists.

分支branchname已存在。它是在此步骤过程中创建的,所有yarn addFilesToCommit都执行一个构建步骤,该步骤将几个JSON文件添加到要跟踪的文件夹中。如果branchname不存在,构建将通过,只有在后续运行中,它才会因错误而失败。

git checkout -b branchname | git checkout branchname
yarn addFilesToCommit
git add .
git commit -m "Sync"
git push --force --set-upstream origin branchname

[我已经尝试过像其他帖子中提到的那样rm -rf /home/circleci/project/.git/index.lockrm -rf /home/circleci/project/.git/index,但是没有运气。

如果我运行内部版本并在其中运行ssh,似乎可以毫无问题地运行命令。我在哪里错了?

git circleci
1个回答
1
投票

用第一行代替git checkout -b branchname && git checkout branchname

© www.soinside.com 2019 - 2024. All rights reserved.