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
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
Copyright © 2021 Jogjafile Inc.
Referring to the official docs:
Cloning with the
--mirroroption you are implicitly using the--bareoption, which create a repository without a working tree.The
--bareoption 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 shouldgit clone your-mirrored-repo(without the--bare/--mirroroption) to have a full working tree, started from the mirrored repo, in which you can use all the git commands or edit files directly.