1

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

Chetan Sharma
  • 173
  • 1
  • 3
  • 16

1 Answers1

2

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'])
ajoberstar
  • 2,575
  • 19
  • 21
  • i get this error -. Caused by: org.eclipse.jgit.api.errors.NoFilepatternException: At least one pattern is required. 19:42:14 at org.eclipse.jgit.api.AddCommand.call(AddCommand.java:140) 19:42:14 at org.eclipse.jgit.api.AddCommand.call(AddCommand.java:85) 19:42:14 at java_util_concurrent_Callable$call$0.call(Unknown Source) 19:42:14 at org.ajoberstar.grgit.operation.AddOp.call(AddOp.groovy:72) 19:42:14 ... 67 more – Chetan Sharma Nov 15 '16 at 07:47
  • Is it like this i need to do ? grgit.add(patterns: ['src'], update: false) grgit.add(patterns: ['src'], update: true) – Chetan Sharma Nov 15 '16 at 07:49
  • Yep, I missed that part. – ajoberstar Nov 15 '16 at 12:11