private void AddItemsToGit(bool initialCheckin) { var directories = Directory.GetDirectories(GitRepositoryFolder, "*.*", SearchOption.AllDirectories).ToList(); directories.RemoveAll(r => r.Contains(".git") || r.Contains("\\Logs")); directories.Add(GitRepositoryFolder); var files = new List<string>(); directories.ForEach(dir => files.AddRange(Directory.GetFiles(dir))); using (var frmStatus = new Status()) { frmStatus.Show(); frmStatus.SetStatusText("Gathering Items to Add to Source Control"); if (initialCheckin) frmStatus.SetMaximum(files.Count); else frmStatus.SetMaximum(files.Count + repo.Status.Added.Count + repo.Status.Removed.Count + repo.Status.Modified.Count); frmStatus.SetStatusText("Adding Items"); string commitMessage = initialCheckin ? "Initial Load of Existing V3 Data Files" : "Updated/Added File to V3 Folders"; if (initialCheckin) files.ForEach(file => { repo.Index.Add(file); repo.Commit(commitMessage); frmStatus.SetStatusText(commitMessage); frmStatus.SetValue(frmStatus.Value + 1); }); // repo.Index.AddAll(); repo.Status.Added.ToList().ForEach(a => { repo.Index.Add(Path.Combine(GitRepositoryFolder, a)); commitMessage = string.Format("Added {0}", new FileInfo(Path.Combine(GitRepositoryFolder, a)).Name); repo.Commit(commitMessage); frmStatus.SetStatusText(commitMessage); frmStatus.SetValue(frmStatus.Value + 1); }); repo.Status.Removed.ToList().ForEach(a => { repo.Index.Add(Path.Combine(GitRepositoryFolder, a)); commitMessage = string.Format("Removed {0}", new FileInfo(Path.Combine(GitRepositoryFolder, a)).Name); repo.Commit(commitMessage); frmStatus.SetStatusText(commitMessage); frmStatus.SetValue(frmStatus.Value + 1); }); repo.Status.Modified.ToList().ForEach(a => { repo.Index.Add(Path.Combine(GitRepositoryFolder, a)); commitMessage = string.Format("Changed {0}", new FileInfo(Path.Combine(GitRepositoryFolder, a)).Name); repo.Commit(commitMessage); frmStatus.SetStatusText(commitMessage); frmStatus.SetValue(frmStatus.Value + 1); }); frmStatus.Close(); } }