@@ -0,0 +1,2526 @@
+package application.util;%0D%0A%0D%0Aimport java.io.File;%0D%0Aimport java.net.URI;%0D%0Aimport java.text.SimpleDateFormat;%0D%0Aimport java.util.Date;%0D%0Aimport java.util.Iterator;%0D%0A%0D%0Aimport org.eclipse.jgit.api.Git;%0D%0Aimport org.eclipse.jgit.api.LogCommand;%0D%0Aimport org.eclipse.jgit.lib.Repository;%0D%0Aimport org.eclipse.jgit.revwalk.RevCommit;%0D%0A%0D%0Apublic class Gits %7B%0D%0A%0D%0A%09public static void push(String fileName)%7B%0D%0A%09%09try %7B%0D%0A%0D%0A%09%09%09URI uri = Gits.class.getResource(%22/%22).toURI();%0D%0A%09%09%09String path = uri.getPath();%0D%0A%09%09%09System.out.println(path);%0D%0A%0D%0A%09%09%09String dir = new File(path).getParentFile().getAbsolutePath() + File.separator + %22.git%22;%0D%0A%09%09%09Git git = Git.open(new File(dir));%0D%0A%0D%0A%09%09%09Repository repository = git.getRepository();%0D%0A%09%09%09System.out.println(repository.getBranch());%0D%0A%0D%0A%09%09%09// git log%0D%0A%09%09%09LogCommand logCommand = git.log();%0D%0A            Iterator%3CRevCommit%3E iterator= logCommand.call().iterator();%0D%0A            while (iterator.hasNext()) %7B%0D%0A                RevCommit revCommit = iterator.next();%0D%0A                System.out.println(new String(revCommit.getRawBuffer()));%0D%0A            %7D%0D%0A%0D%0A            /******************************************************************************%0D%0A             * ------------------------- git add %C3%B7 -------------------------%0D%0A             * %CA%BE%3Cpath%3Etracked%C4%BC%D0%B1%DE%B8%C4%B9%C9%BE%C4%BCuntracted%C4%BC%CF%A2%D3%B5%E2%A1%A3%0D%0A             * addFilepattern(%22. -A%22).call()%0D%0A             * addFilepattern(%22README%22).call()%0D%0A             * --------------------------------------------------------------%0D%0A             *****************************************************************************/%0D%0A            git.add().addFilepattern(%22.%22).call();%0D%0A%0D%0A            // git commit%0D%0A            SimpleDateFormat sf = new SimpleDateFormat(%22yyyy-MM-dd hh:mm:ss%22);%0D%0A            StringBuffer message = new StringBuffer();%0D%0A            message.append(%22=======%22);%0D%0A            message.append(%22update %22);%0D%0A            message.append(fileName);%0D%0A            message.append(%22 on %22);%0D%0A            message.append(sf.format(new Date()));%0D%0A            message.append(%22=======%22);%0D%0A            git.commit().setAll(true).setAuthor(%22wangli0%22, %22xx@qq.com%22).setMessage(message.toString()).call();%0D%0A%0D%0A%09        // https %CA%BD%E1%BD%BB%0D%0A            // git.push().setCredentialsProvider(new UsernamePasswordCredentialsProvider(username,password)).call();%0D%0A%0D%0A            // ssh%CA%BD%E1%BD%BB%0D%0A            AllowHostsCredentialsProvider allowHosts = new AllowHostsCredentialsProvider();%0D%0A            git.push().setCredentialsProvider(allowHosts).call();%0D%0A%0D%0A%09%09%7D catch (Exception e1) %7B%0D%0A%09%09%09e1.printStackTrace();%0D%0A%09%09%7D%0D%0A%09%7D%0D%0A%7D%0D%0A

add gits