I'm trying to clone a GitHub repository into a existing, non-empty directory. I tried mimicking the way it's done using the git command line:
git init
git remote add origin https://github.com/[...].git
git fetch
git reset --hard origin/branch
var git = Git.Init().SetDirectory(Location).Call();
Repository = git.GetRepository();
var config = Repository.GetConfig();
config.SetString("remote", "origin", "url", "https://github.com/[...].git");
config.Save();
git.Fetch().Call();
git.Reset().SetRef("origin/branch")
.SetMode(ResetCommand.ResetType.HARD).Call();
In this particular case I got a "Nothing to fetch" error. I've tried a number of different things, including cloning into a temporary dictionary, using BranchCreate, ... but I've always ran into an issue somewhere.
So how would you go about properly cloning a repository and set it up to fetch updates in the future?