Git无法锁定引用,无法创建引用

Ale*_*lls 5 git git-checkout

我收到此错误:

fatal: cannot lock ref 'refs/heads/oleg/feature/1535693040/squashed':
Run Code Online (Sandbox Code Playgroud)

'refs/heads/oleg/feature/1535693040' 存在;无法创建 'refs/heads/oleg/feature/1535693040/squashed'

产生错误的脚本是:

current_branch="$(git rev-parse --abbrev-ref HEAD)"

git checkout -b "$current_branch/squashed"
git reset --soft "remotes/origin/dev";

git add .
git add -A
git commit -am "ores/gitflow auto-commit (squashed)"
git push
Run Code Online (Sandbox Code Playgroud)

有人知道那是什么吗?

Ale*_*lls 11

啊,我找到了答案:https : //stackoverflow.com/a/22630664/1223975

简而言之,如果:a/b/c存在,Git 不能创建a/b/c/d

不知道为什么

  • 我试图在我的回答中解释评论中的“为什么”。不过,这很棘手,但没有侮辱性,因为“为什么”归结为“Git 作者很懒”:-)(懒惰有时是编程的一种美德......)请注意,如果你运行 `echo foo > dir`接下来是`mkdir dir`,以便您可以运行`echo bar > dir/file`,您会在`mkdir`步骤中收到错误。这是同样的问题。 (2认同)