6

I get this error:

fatal: cannot lock ref 'refs/heads/oleg/feature/1535693040/squashed':

'refs/heads/oleg/feature/1535693040' exists; cannot create 'refs/heads/oleg/feature/1535693040/squashed'

the script that generated the error was:

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

anyone know what that is about?

Alexander Mills
  • 90,741
  • 139
  • 482
  • 817

1 Answers1

15

Ahh I found an answer to this: https://stackoverflow.com/a/22630664/1223975

in short, if: a/b/c exists, Git cannot create a/b/c/d

not sure why tho

Alexander Mills
  • 90,741
  • 139
  • 482
  • 817
  • 2
    I tried to explain the "why" in comments in my answer there. It's tricky, though, without being insulting, because the "why" boils down to "Git authors are lazy" :-) (Laziness is sometimes a virtue in programming...) Just note that if you run `echo foo > dir` followed by `mkdir dir` so that you can run `echo bar > dir/file`, you get an error at the `mkdir` step. This is the same issue. – torek Sep 01 '18 at 00:12
  • @torek `echo foo > dir` is going to create a regular file named dir, so `mkdir dir` is going to fail, so how this related to laziness issue? Are you suggesting unix should allow a regular file and directory with same name? – Sameer Naik Mar 26 '19 at 03:11
  • 1
    @SameerNaik: no (well, yes, actually, but that would violate POSIX rules, but it's not needed here anyway). What Git *should* be doing is not using files named `a/b/c/d` to hold branch tip values. It already isn't using files like that when the refs are "packed" into `.git/packed-refs`. It should be using a simple database so that it does not depend on OS facilities. But that requires writing a simple database. – torek Mar 26 '19 at 05:42