public abstract class Gits extends Object implements SafeCloseable
checkout pull reset log branch clean
其他功能请用命令行
| Modifier | Constructor and Description |
|---|---|
protected |
Gits(org.eclipse.jgit.api.Git git) |
| Modifier and Type | Method and Description |
|---|---|
Gits |
auth(String username,
char[] password)
认证用户
|
Gits |
auth(String username,
String password) |
List<BranchInfo> |
branchList() |
List<BranchInfo> |
branchList(String branch)
分支列表
|
Gits |
checkout(String branchName)
检出分支
|
Gits |
clean()
清空工作目录其他文件
|
static Gits |
clone(String url,
File path) |
static Gits |
clone(String url,
File path,
String username,
char[] password)
clone 仓库
可以使用 accessToken
github username: token password: ''
github username: '' password: token
gitee username: username password: token
gitlab username: oauth2 password: token url: https://oauth2:token@url
|
static Gits |
clone(String url,
File path,
String username,
String password) |
void |
close()
安全关闭
|
Gits |
fetch() |
Gits |
fetch(String remote)
fetch
|
String |
getBranch()
获取当前分支
|
String |
getDirectory()
获取目录
|
org.eclipse.jgit.api.Git |
getGit() |
org.eclipse.jgit.lib.Ref |
getRef(String name)
获取ref
|
String |
getRemoteUrl()
获取远程url
|
org.eclipse.jgit.lib.Repository |
getRepository() |
boolean |
hasRef(String name)
检查ref
|
List<LogInfo> |
logList() |
List<LogInfo> |
logList(int count) |
List<LogInfo> |
logList(String branch) |
List<LogInfo> |
logList(String branch,
int count) |
static Gits |
of(File path) |
static Gits |
of(org.eclipse.jgit.api.Git git) |
static Gits |
of(org.eclipse.jgit.lib.Repository repo) |
Gits |
pull() |
Gits |
pull(String remote) |
Gits |
pull(String remote,
String remoteBranch)
pull
|
Gits |
push(String remote)
push
|
Gits |
rebase() |
Gits |
rebase(org.eclipse.jgit.api.RebaseCommand.Operation operation)
rebase
|
Gits |
reset(String commitId) |
Gits |
reset(String commitId,
org.eclipse.jgit.api.ResetCommand.ResetType type)
还原版本
|
public static Gits of(org.eclipse.jgit.api.Git git)
public static Gits of(org.eclipse.jgit.lib.Repository repo)
public static Gits clone(String url, File path, String username, char[] password)
可以使用 accessToken
github username: token password: '' github username: '' password: token gitee username: username password: token gitlab username: oauth2 password: token url: https://oauth2:token@url
url - remoteUrlpath - 本地路径username - 用户名password - 密码public Gits auth(String username, char[] password)
username - usernamepassword - passwordpublic Gits pull()
public Gits pull(String remote, String remoteBranch)
remote - 远程主机remoteBranch - 远程分支public Gits fetch()
public Gits rebase()
public Gits rebase(org.eclipse.jgit.api.RebaseCommand.Operation operation)
operation - operationpublic Gits reset(String commitId, org.eclipse.jgit.api.ResetCommand.ResetType type)
commitId - commitIdtype - 类型public List<BranchInfo> branchList()
public List<BranchInfo> branchList(String branch)
branch - 分支名称public Gits clean()
public String getDirectory()
public String getRemoteUrl()
public String getBranch()
public boolean hasRef(String name)
name - namepublic org.eclipse.jgit.lib.Ref getRef(String name)
name - namepublic org.eclipse.jgit.api.Git getGit()
public org.eclipse.jgit.lib.Repository getRepository()
public void close()
SafeCloseableclose in interface SafeCloseableclose in interface Closeableclose in interface AutoCloseableCopyright © 2025. All rights reserved.