Reputation: 97
Is it possible to get all the changed/added/removed files from a repository, and then stage those files? If yes, how?
I was doing something like this:
foreach (string file in Directory.GetFiles("dir/repo", "*", SearchOption.AllDirectories))
{
repo.Stage(file);
}
However, it does not satisfy me because I stage all of the untracked files. But I want to stage all of the modified/added/deleted files.
Upvotes: 2
Views: 1611
Reputation: 67589
Is it possible to get all the changed/added/removed files from a repository, and then stage those files? If yes, how?
"Use the wildcard, Luke!" ;-)
repo.Stage("*")
will mimic git add --all
(from git documentation: "Update the index not only where the working tree has a file matching but also where the index already has an entry. This adds, modifies, and removes index entries to match the working tree.")
See CanMimicGitAddAll() test from IndexFixture.cs
for some additional insights.
Upvotes: 2
Reputation: 875
You can use git command line tools to get lists of changed/added/removed files. Just Google it and you will find plenty of resources.
Take a look at how to run a command line tool and get the output as a string:
I think that's all you need.
Upvotes: -1