蛋糕中的Git克隆问题

时间:2017-05-15 11:11:39

标签: git git-clone git-checkout cakebuild

使用以下链接克隆源

http://cakebuild.net/api/Cake.Git/GitAliases/2ACDDC0F

GitClone("https://github.com/cake-build/cake.git", 
    "c:/temp/cake", 
    "username", 
    "password",
    new GitCloneSettings{ BranchName = "development" });

它适用于克隆分支源。

当我使用标签名称(tags / 12.4.2.1)而不是branchName面对下面的问题

参考&ref; / remotes / origin / tags / 12.4.2.1'找不到

注意:标签/ 12.4.2.1存在

1 个答案:

答案 0 :(得分:0)

作为一个起点,目前只找到解决方法, 通过cmd执行git clone specific tag commands StartProcess

    Task("Default")
        .Does(() =>
        {
            GitClone("https://github.com/cake-build/cake.git", 
                "d:/temp/cake", 
                "userName", 
                "password",
                new GitCloneSettings{ BranchName = "main" });

            Cmd("cd /D D:\\temp\\cake",
                " & git checkout v0.8.0",
                " & git branch -D main",
                " & git checkout -b main");
        });

private void Cmd(params object[] parameters)
{
    if (parameters.Any())
    {
        var args =  new ProcessArgumentBuilder()
            .Append(@"/c");

        foreach (var param in parameters)
            args.Append($"{param}");

        StartProcess("cmd", new ProcessSettings { Arguments = args });
    }
}