/// <summary> /// Requires absolute path /// </summary> /// <param name="fileName"></param> public void StageFile(string fileName) { if (!this.HasGitRepository) { return; } //var index = repository.GetIndex(); //index.RereadIfNecessary(); if (GitBash.Exists) { if (File.Exists(fileName)) { GitBash.Run(string.Format("add \"{0}\"", GetRelativeFileName(fileName)), this.GitWorkingDirectory); } else { GitBash.Run(string.Format("rm --cached -- \"{0}\"", GetRelativeFileName(fileName)), this.GitWorkingDirectory); } } else { if (File.Exists(fileName)) { AddCommand addCommand = new Git(repository).Add(); addCommand.AddFilepattern(GetRelativeFileNameForGit(fileName)); addCommand.Call(); } else { RmCommand rmCommand = new Git(repository).Rm(); rmCommand.AddFilepattern(GetRelativeFileNameForGit(fileName)); rmCommand.Call(); } } this.cache.Remove(GetCacheKey(fileName)); this.changedFiles = null; }