The following Powershell function will add all files not yet added, then do a commit with the message provided in the call to the function, then do the push. The prerequisite is that the “GIT” command line is installed and available. I was earlier looking for an API, but I think this is the apparently the best way of accomplishing the commit.

# Tested 01/25/2019 - by adding a test file and running this script 

function GitAddCommitPushDir ($directory, $commitMessage) 
    cd $dirname 
    git add .
    git commit -m $commitMessage
    git push

$dirName = "d:\Git\MyCodeDir"
GitAddCommitPushDir $dirName "Test commit by Powershell Script" 


Filed under: PowershellUncategorized