How to checkout a bare repository? #838
-
Hi, thank you for your awesome work! I want to checkout the head commit from the bare repository to some working folder, then I wrote the code referring to the method here: pub fn checkout_head(&self, dst_path: impl AsRef<Path>) -> anyhow::Result<()> {
let dst_path = dst_path.as_ref();
let git_path = self.path.clone();
debug!("index path: {}", git_path.join("index").as_path().display());
let mut index = gix_index::File::at(git_path.join("index"), Sha1, Default::default())?;
let odb = gix::odb::at(git_path.join("objects"))?
.into_inner()
.into_arc()?;
let _outcome = gix_worktree::checkout(
&mut index,
dst_path,
move |oid, buf| odb.find_blob(oid, buf),
&mut progress::Discard,
&mut progress::Discard,
&AtomicBool::default(),
gix_worktree::checkout::Options {
overwrite_existing: true,
..Default::default()
},
)?;
Ok(())
} But it failed with message any other ways that could do this? thank you for you help! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
the method in git goes here:
|
Beta Was this translation helpful? Give feedback.
-
Indices can be created on the fly by using a tree object. However, please note that at this time the checkout implementation is nothing more than experimental, a lot of the required implementation is missing. Further, I wonder if I hope that helps. |
Beta Was this translation helpful? Give feedback.
Indices can be created on the fly by using a tree object.
However, please note that at this time the checkout implementation is nothing more than experimental, a lot of the required implementation is missing.
Further, I wonder if
git worktree
would be suitable for your use-case. There is alsogit archive
if detached worktrees are desired, even though there is nogix
counterpart yet.I hope that helps.