天天看点

JGIT AddCommand add无效,jgit add()方法调用

Windows下使用JGIT操作git,但是使用下面的API始终无法添加文件到index,仔细查看JGIT API才发现端倪

Git.open(gitHome).add().addFilepattern(filePattern).call();
           
  1. filePattern使用相对路径
  2. filePattern使用"/"作为分隔符

所以在windows下使用相对路径,还需要替换路径分隔符"\"为"/"

JGIT AddCommand add无效,jgit add()方法调用

附:

1.JGIT API: http://mirror.neu.edu.cn/eclipse/jgit/docs/latest/apidocs.old/org/eclipse/jgit/api/AddCommand.html

2.JGit/User Guide: https://wiki.eclipse.org/JGit/User_Guide#AddCommand_.28git-add.29