- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在使用 JGit 从我的 git 存储库中 checkout 分支并修改文件。提交更改后,我尝试推送它,但遇到了 TransportException:
Caused by: org.eclipse.jgit.errors.TransportException: Nothing to push.
at org.eclipse.jgit.transport.Transport.push(Transport.java:1332)
at org.eclipse.jgit.api.PushCommand.call(PushCommand.java:169)
...
我的代码如下所示:
this.checkoutBranch(branchName);
try (Writer writer = new OutputStreamWriter(new FileOutputStream(getFilePath(filepath).toFile(), true),
StandardCharsets.UTF_8))
{
Yaml yaml = this.initializeYaml();
Map<String, Object> parameterMap = this.getParameterMap(filepath, yaml);
parameterMap.put(key, value);
// write file
yaml.dump(parameterMap, writer);
// commit and push
git.add().addFilepattern(filepath).call();
git.commit().setMessage("Added parameter with key: '" + key + "'").call();
git.push().setCredentialsProvider(getCredentialProvider()).call();
}
catch(GitAPIException | IOException e)
{
throw new GitClientException("Cannot write parameters.", e);
}
以下是检查当前分支的方法:
public void checkoutBranch(String branchName)
{
try
{
git.checkout().setName("origin/" + branchName).call();
}
catch(GitAPIException e)
{
throw new GitClientException("Cannot checkout branch.", e);
}
}
我查找了 JGit 示例,发现了很多,但没有示例处理文件更改。有人提示可能出了什么问题吗?
最佳答案
调用checkoutBranch
将导致HEAD分离,这可能是push命令失败的原因。
git.getRepository().getFullBranch()
现在返回远程分支指向的提交的对象 ID (SHA-1)。
要在不分离 HEAD 的情况下 check out 远程分支,Git 需要创建一个本地分支作为代理并跟踪远程分支。请参阅JGit: Checkout a remote branch了解如何使用 JGit 实现此目的。
关于java - 使用 JGit 推送更改的文件时遇到 TransportException "Nothing to push",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51496146/
我正在安装 Laravel 4 并运行“composer install”命令。它能够成功安装 13 个软件包,但是当需要安装 symfony/translation 时,它 100% 下载了它,然后
我们将Elasticsearch集群从2.1.1升级到2.2。我们通过2.2.1之前版本运行的bulkload处理器进行的批量加载过程现在引发以下异常。如果我想念什么,请告诉我。我是这个新手。 [ma
当客户端尝试查询 cosmos 时,会看到大量对象引用未设置到对象实例异常。 深入检查后,异常消息包含如下详细信息: { "CPU Load History":{ "CPU Hist
我正在使用 JGit 从我的 git 存储库中 checkout 分支并修改文件。提交更改后,我尝试推送它,但遇到了 TransportException: Caused by: org.eclips
当客户端尝试查询 cosmos 时,会看到大量对象引用未设置到对象实例异常。 深入检查后,异常消息包含如下详细信息: { "CPU Load History":{ "CPU Hist
大家好,我已经遇到这个问题好几天了,当我尝试使用 composer 为我的 php 项目下载依赖项时出现此错误 c:\wamp64\www\Test>composer global require "
安装 composer 后,我用这个命令检查它: composer diagnose 一切正常。当我为最新版本的 Laravel 运行此命令时: composer global require "la
当我尝试使用此命令创建 ScalaTest 示例时: sbt new scala/scalatest-example.g8 fails on TransportException 我得到以下信息: [
我正在尝试使用 SSHJ 登录其他机器。下面的 PFA 代码(不包括 try/catch/finally block )。 Security.addProvider(new org.bouncycas
这是我的Eureka Server 应用程序。property # set port server.port=8761 # no need to register the server with th
我是微服务的新手,正在尝试从链接运行代码:https://dzone.com/articles/advanced-microservices-security-with-spring-and-oa .
我正在尝试更新项目中的 Zend Framework 2 库并遇到异常: use@machine:/path/to/project# php composer.phar self-update [Co
Eureka 服务器无法在 Docker compose 上运行 这是 Eureka 服务器和配置服务器的 docker-compose version: '3' services: fete
我是微服务新手。我正在尝试创建一个用于学习目的的小型应用程序。这是我的代码:EurekaServer - application.yml spring: application:
我是一名优秀的程序员,十分优秀!