I have cloned my repo using --mirror
flag, can I checkout branch from it if yes how? if no why ?
git branch
shows me list of all branches but git checkout branch-name
gives me error saying:
fatal: This operation must be run in a work tree
Referring to the official docs:
--mirror
Set up a mirror of the source repository. This implies
--bare
. Compared to--bare
,--mirror
not only maps local branches of the source to local branches of the target, it maps all refs (including remote-tracking branches, notes etc.) and sets up a refspec configuration such that all these refs are overwritten by agit remote update
in the target repository.
Cloning with the --mirror
option you are implicitly using the --bare
option, which create a repository without a working tree.
The --bare
option is used mainly at server-side or in specific use cases.
In your case you shouldn't directly use your mirrored repo, as not having a working tree, is not suitable for editing files or for git commands as git checkout
.
You should git clone your-mirrored-repo
(without the --bare
/--mirror
option) to have a full working tree, started from the mirrored repo, in which you can use all the git commands or edit files directly.