2016-08-05 20 views
1

是否可以通過grgit插件提交gradle中的一個文件?是否可以通過grgit插件提交gradle只有一個文件?

我修改了version.properties文件,我只需要使用grgit插件僅將該特定文件提交回git。

但是,當我提交回git整個項目被提交回git分支。

我的代碼

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

回答

2

grgit.commitall選項類似於git commit -a標誌。它會將更改提交到所有跟蹤的文件。要只提交一個,你需要先將它添加到索引,然後提交。

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 
} 
+0

Thanks @ajoberstar ...是否有可能在提交和推送更改時創建標籤。 –

+0

您可能想爲此發佈第二個問題。 – ajoberstar

相關問題