0

I am trying to create a bare git repo, git clone into another directory, and do the git add . & git commit & git push. However, I could not successfully complete git add . After I did git add ., I checked by git status , the target file hasn't been added.

The code I tried as follows:

let mut index = repo.index().unwrap();
&index.add_all(&["."], git2::IndexAddOption::DEFAULT, None)?;
let oid = index.write_tree()?;
let signature = git2::Signature::now("secure-crates","abc@gmail.com")?;
let tree = repo.find_tree(oid)?;
let msg :&str = "Inital Commit";
repo.commit(Some("HEAD"), &signature, &signature, &msg, &tree, &[])?;
let mut remote = repo.find_remote("origin")?;
remote.push::<&'static str>(&[], None)?;

Is anybody know how to do git add operation for a bare repo?

kmdreko
  • 42,554
  • 6
  • 57
  • 106

0 Answers0