libgit2sharp
libgit2sharp copied to clipboard
how can use Commit like $ git commit [file1] [file2] ... -m [message]
for some reason I need Use Commands.Stage(repository,"*") Stage All File then if I only want to commit a part of files How to Implemented this
in git cmd git commit 1.txt 2.txt -m "1commit"
You can iterate through the file list (after getting from command line arguments) and stage them like following,
foreach(var file in fileList) {
Repo.Index.Add(FilePath);
Repo.Index.Write();
}
Then, you call commit and push. Hope this hint helps. :)
I needed this for the following use-case. I have 1 modified file (not staged) in changeset, and 1 untracked file in unversioned. I stage the untracked file, so it appears in the changeset. Now, the changeset contains two files. I tick mark the modified file and commit (behind the scenes it also stages the file). The pain point is that both the files get committed, because I staged the untracked file. If I have an option where I can only commit specific files from the staging area just like the command line, that would fix this problem.
@uddeeqtkg this is not an issue, more like a general question. It might be good idea to move it to stackoverflow and tag with libgit2sharp
?