Spencer Bharath
Spencer Bharath

Reputation: 567

Is it possible to commit only one file through grgit plugin for gradle.?

Is it possible to commit only one file through grgit plugin for gradle.?

I have modified the version.properties file and I need to commit only that particular file back to git using grgit plugin.

But when i Commit back to git whole project is getting committed back to git branch .

my code

task pushToGit
{
    def grgit = org.ajoberstar.grgit.Grgit.open(dir: '.')
    grgit.commit(message: 'Committing Version Property Changes', all: true)
    grgit.push(force: true)
}

Upvotes: 1

Views: 935

Answers (1)

ajoberstar
ajoberstar

Reputation: 2585

The all option on grgit.commit is similar to the git commit -a flag. It will commit changes to all tracked files. To only commit one, you need to add it to the index first, then commit.

task pushToGit
{
    def grgit = org.ajoberstar.grgit.Grgit.open(dir: '.')
    grgit.add(patterns: ['version.properties'])
    grgit.commit(message: 'Committing Version Property Changes')
    grgit.push(force: true) // not sure I would recommend this
}

Upvotes: 2

Related Questions