我正在使用JGit克隆存储库,对文件进行一些更改,提交,标记它,然后将其推送到远程存储库。
我已经使用JGit编写了代码,它将克隆存储库,对文件进行一些更改,然后提交更改,创建新标签并推送提交和标签。
Git git = Git.cloneRepository()
.setURI("https://*****@stash.dts.*****.git")
.setDirectory(outputFolder)
.call();
// Some code to update the file
git.add().addFilepattern(".").call();
git.commit().setMessage("File Commit").call();
// Creating tag
git.tag().setName(version).setForceUpdate(true).call();
// Pushing the commit and tag
git.push().call();
推送后,我希望远程存储库显示我的更改和新标记,但是带有commitId的更改显示在远程仓库中,但标记不可见。它显示“无标签”。
答案 0 :(得分:1)
要推送所有标签,您需要在调用PushCommand
之前启用此功能。
例如:
List<PushResult> pushResult = git.push().setPushTags().call();
或者,您可以使用PushCommand::setRefSpecs
设置要推送的refspecs列表。