diff --git a/src/GitHub.Api/Git/GitClient.cs b/src/GitHub.Api/Git/GitClient.cs index d3bc60351..5e454f6fa 100644 --- a/src/GitHub.Api/Git/GitClient.cs +++ b/src/GitHub.Api/Git/GitClient.cs @@ -325,7 +325,11 @@ public ITask AheadBehindStatus(string gitRef, string other public ITask> Log(BaseOutputListProcessor processor = null) { return new GitLogTask(new GitObjectFactory(environment), cancellationToken, processor) - .Configure(processManager); + .Configure(processManager) + .Catch(exception => exception is ProcessException && + exception.Message.StartsWith("fatal: your current branch") && + exception.Message.EndsWith("does not have any commits yet")) + .Then((success, list) => success ? list : new List()); } /// @@ -596,7 +600,11 @@ public ITask Unlock(NPath file, bool force, public ITask GetHead(IOutputProcessor processor = null) { return new FirstNonNullLineProcessTask(cancellationToken, "rev-parse --short HEAD") { Name = "Getting current head..." } - .Configure(processManager); + .Configure(processManager) + .Catch(exception => exception is ProcessException && + exception.Message.StartsWith("fatal: your current branch") && + exception.Message.EndsWith("does not have any commits yet")) + .Then((success, head) => success ? head : null); } protected static ILogging Logger { get; } = LogHelper.GetLogger();