git setup/usage question

Mark Millard marklmi at yahoo.com
Tue Jan 26 20:51:49 UTC 2021


Milan Obuch freebsd-git at dino.sk wrote on
Tue Jan 26 14:10:29 UTC 2021 :

> # git clone --config remote.freebsd.fetch='+refs/notes/*:refs/notes/*' --bare https://git.freebsd.org/src.git
>  /mnt/src/.git
> # git -C /mnt/src/.git worktree add /mnt/src/main main
> # git -C /mnt/src/.git worktree add /mnt/src/13 stable/13
> # git -C /mnt/src/.git worktree add /mnt/src/12 stable/12
> # git -C /mnt/src/.git worktree add /mnt/src/11 stable/11
. . .
> # git -C /mnt/src/.git merge
> fatal: this operation must be run in a work tree
> 
> I am a bit stuck now. What does it mean 'being in a work tree'? Doing
> 'cd /mnt/src/main' or similar before git command does not change
> anything. I read 'man git-merge' but still no clue. It must be
> something simple, I just do not see it.

man git reports:

       -C <path>
           Run as if git was started in <path> instead of the current working
           directory. . . .

So it looks to me like you need to do one or
more of something like:

# git -C /mnt/src/main merge
# git -C /mnt/src/stable/13 merge
# git -C /mnt/src/stable/12 merge
# git -C /mnt/src/stable/11 merge

/mnt/src/.git is not a working directory.

Note that

# git -C /mnt/src/.git log

has the same sort of issue.

The other commands that you list (clone, worktree add,
worktree list, fetch) do not depend on having some
specific, pre-existing worktree (working directory) as
context for those operations. For those, referencing
the .git directory tree works.

/mnt/src/main , /mnt/src/stable/13 , /mnt/src/stable/12 ,
and /mnt/src/stable/11 all include information pointing
to /mnt/src/.git as what they are tied to. So they tend
to also work where /mnt/src/.git references are okay.

===
Mark Millard
marklmi at yahoo.com
( dsl-only.net went
away in early 2018-Mar)



More information about the freebsd-git mailing list