libgit2sharp icon indicating copy to clipboard operation
libgit2sharp copied to clipboard

how can use Commit like $ git commit [file1] [file2] ... -m [message]

Open uddeeqtkg opened this issue 3 years ago • 3 comments

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"

uddeeqtkg avatar Jul 27 '21 09:07 uddeeqtkg

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. :)

atiq-cs avatar Nov 08 '21 19:11 atiq-cs

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.

thealifaisal avatar Nov 25 '21 16:11 thealifaisal

@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 ?

atiq-cs avatar Nov 25 '21 18:11 atiq-cs