grgit - to add new files and remove deleted files

713 Views Asked by At

we are using grgit to update files in github.

def grgit = Grgit.open(dir: repoDir)
    grgit.add(patterns: ['src'], update: false) // False should even add new files
    grgit.commit(message: 'Updated subsets', amend: false)
    grgit.push()

we checkout from git and delete, add, modify files in a directory and commit and push directory back to github.

now while we do grgit.add and keep update:false it Add new files but doesn't remove deleted files. and if we do update:true it doesn't add the new files and only do changes to tracked files.

how to add and remove files together like git add -A in grgit. please help

1

There are 1 best solutions below

3
ajoberstar On BEST ANSWER

Grgit is based on JGit, which does not currently have an equivalent to git add -A.

You have to do this as two separate steps:

grgit.add(patterns: ['src'], update: true)
grgit.add(patterns: ['src'])