我制作了一个程序来从我的github托管的公共存储库中提取。克隆一个项目工作得很好(无论如何我都这样做),但我一直试图让它工作来拉动所有东西,一旦你删除它不再拉该文件的文件。在我的情况下,我从拉出的存储库中删除了.gitignore(基本上是克隆的),现在repo.Network.Pull()
不想从存储库重新下载它。与我删除的任何其他文件相同。
private void PullButton_Click(object sender, EventArgs e)
{
if (!string.IsNullOrWhiteSpace(BrowseText.Text))
if (Directory.Exists(BrowseText.Text))
{
AddToDebugBox("Starting Pull request to \"" + BrowseText.Text + "\"...");
if (!Repository.IsValid(BrowseText.Text))
{
AddToDebugBox("No Git init found at: \"" + BrowseText.Text + "\"...");
Repository.Clone("https://github.com/sxbrentxs/FPS-GLU.git", BrowseText.Text);
AddToDebugBox("Created new git init at: \"" + BrowseText.Text + "\".");
}
else
{
AddToDebugBox("Found git init at: \"" + BrowseText.Text + "\".");
using (Repository repo = new Repository(BrowseText.Text))
{
AddToDebugBox("Starting pull request...");
PullOptions options = new PullOptions();
options.FetchOptions = new FetchOptions();
repo.Network.Pull(new Signature("Updater", "Updater@RoZoShoGitUpdater.nl", new DateTimeOffset(DateTime.Now)), options);
AddToDebugBox("Completed pull request.");
AddToDebugBox("Calculating differences...");
TreeChanges changes = repo.Diff.Compare<TreeChanges>();
AddToDebugBox(string.Format("{0} files changed.", changes.Count()));
foreach (TreeEntryChanges c in changes)
AddToDebugBox(string.Format("Path: {0} | Change made: {1}", c.Path, c.Status));
}
AddToDebugBox("Operations completed.");
cleanready = !cleanready;
}
}
else
AddToDebugBox("Cannot pull to non-existing path: \"" + BrowseText.Text + "\"...");
else
AddToDebugBox("Cannot pull to nothing: \"" + BrowseText.Text + "\"...");
}
这是我按下拉按钮时的日志:
23:41:55 > Folder: "E:\Projects\Test" selected.
23:41:58 > Starting Pull request to "E:\Projects\Test"...
23:41:58 > Found git init at: "E:\Projects\Test".
23:41:58 > Starting pull request...
23:41:59 > Completed pull request.
23:41:59 > Calculating differences...
23:41:59 > 1 files changed.
23:41:59 > Path: .gitignore | Change made: Deleted
23:41:59 > Operations completed.
我忘了或做错了什么?
答案 0 :(得分:2)
您只需要像使用git
的cmd行一样强制结帐:
强制结帐到“主”分支头部的示例:
head = repo.Branches.Single (branch => branch.FriendlyName == "master");
var checkoutOptions = new CheckoutOptions ();
checkoutOptions.CheckoutModifiers = CheckoutModifiers.Force;
repo.Checkout (head, checkoutOptions);