本文整理汇总了C#中Branch.Checkout方法的典型用法代码示例。如果您正苦于以下问题:C# Branch.Checkout方法的具体用法?C# Branch.Checkout怎么用?C# Branch.Checkout使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Branch
的用法示例。
在下文中一共展示了Branch.Checkout方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Execute
public override void Execute()
{
if (Patch && (Track || BranchCreate.Length > 0 || RefLog || Merge || Force))
throw new ArgumentException("--patch is incompatible with all other options");
if (Force && Merge)
throw new ArgumentException("git checkout: -f and -m are incompatible");
if (Track && !(BranchCreate.Length > 0))
throw new ArgumentException("Missing branch name; try -b");
if (Arguments.Count == 0)
Arguments.Add("HEAD");
//Create a new branch and reassign the Repository to the new location before checkout.
if (BranchCreate.Length > 0)
{
Branch.Create(Repository, BranchCreate);
Arguments[0] = BranchCreate;
}
if (Arguments.Count == 1)
{
//Checkout the branch using the SHA1 or the name such as HEAD or master/HEAD
Branch b = new Branch(Repository, Arguments[0]);
if (b != null)
{
b.Checkout();
return;
}
}
//Todo: Add FileNameMatcher support. To be added when fnmatch is completed.
//For now, pattern matching is not allowed. Please specify the files only.
//Gain access to the Git index using the repository determined before command execution
Index index = new Index(Repository);
foreach (string arg in Arguments)
{
//Use full paths only to eliminate platform-based directory differences
string path = Path.GetFullPath(Path.Combine(Directory.GetCurrentDirectory(), arg));
//Perform the validity tests outside of the index to handle the error messages
if ((new FileInfo(path).Exists) || (new DirectoryInfo(path).Exists))
index.Checkout(path);
else
results.FileNotFoundList.Add(path);
}
}