推到GitHub被拒绝的抢劫拒绝

发布于 2025-01-30 15:38:34 字数 9912 浏览 2 评论 0原文

我花了几个小时尝试将项目与Maven一起发布到Github。这通常不是问题,但由于某种原因是这个项目,我不明白为什么。我使用的是Java 1.8.0_312和GIT 2.36.1的Maven 3.8.5。这是pom.xml文件:

<?xml version="1.0" encoding="UTF-8"?>

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>se.company.myproject</groupId>
    <artifactId>myproject</artifactId>
    <version>4.0.0</version>
    <packaging>pom</packaging>

    <name>myproject-base</name>
    <!-- FIXME change it to the project's website -->
    <url>http://www.example.com</url>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <java.version>1.8</java.version>
        <slf4j.version>1.7.36</slf4j.version>
    </properties>

    <modules>
        <module>module1</module>
        <module>module2</module>
        <module>module3</module>
    </modules>

    <scm>
        <connection>scm:git:ssh://[email protected]/mycompany/myproject.git</connection>
        <developerConnection>scm:git:ssh://[email protected]/mycompany/myproject.git</developerConnection>
        <url>https://github.com/mycompany/myproject.git</url>
        <tag>4.0.0</tag>
    </scm>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.slf4j</groupId>
                <artifactId>slf4j-api</artifactId>
                <version>${slf4j.version}</version>
            </dependency>
            <dependency>
                <groupId>se.company.myproject</groupId>
                <artifactId>some-internal-dependency</artifactId>
                <version>5.0.1</version>
            </dependency>
            <!-- Test dependencies -->
            <dependency>
                <groupId>org.assertj</groupId>
                <artifactId>assertj-core</artifactId>
                <version>3.9.1</version>
            </dependency>
            <dependency>
                <groupId>junit</groupId>
                <artifactId>junit</artifactId>
                <version>4.13.2</version>
            </dependency>
            <dependency>
                <groupId>org.slf4j</groupId>
                <artifactId>slf4j-log4j12</artifactId>
                <version>${slf4j.version}</version>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.10.1</version>
                <configuration>
                    <source>${java.version}</source>
                    <target>${java.version}</target>
                    <encoding>${project.build.sourceEncoding}</encoding>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-release-plugin</artifactId>
                <version>3.0.0-M5</version>
                <configuration>
                    <tagNameFormat>@{project.version}</tagNameFormat>
                    <autoVersionSubmodules>true</autoVersionSubmodules>
                </configuration>
            </plugin>
        </plugins>
    </build>


    <distributionManagement>
        <repository>
            <id>company-releases</id>
            <name>Internal Releases</name>
            <url>https://company.se/company-maven-releases/</url>
        </repository>
        <snapshotRepository>
            <id>company-snapshots</id>
            <name>Internal Snapshots</name>
            <url>https://company.se/company-maven-snapshots/</url>
        </snapshotRepository>
    </distributionManagement>

    <repositories>
        <repository>
            <id>company-releases</id>
            <url>https://company.se/company-maven-releases/</url>
        </repository>
    </repositories>
</project>

当我运行maven版本时:准备我得到了:

[INFO] [INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ myproject-module3 ---
[INFO] [INFO] Building jar: /Users/me/code/module3/target/myproject-module3-4.0.0.jar
[INFO] [INFO] ------------------------------------------------------------------------
[INFO] [INFO] Reactor Summary for myproject-base 4.0.0:
[INFO] [INFO] 
[INFO] [INFO] myproject-base ..................................... SUCCESS [  0.059 s]
[INFO] [INFO] module1............................................. SUCCESS [  1.097 s]
[INFO] [INFO] module2 ............................................ SUCCESS [  0.603 s]
[INFO] [INFO] module3 ............................................ SUCCESS [  0.046 s]
[INFO] [INFO] ------------------------------------------------------------------------
[INFO] [INFO] BUILD SUCCESS
[INFO] [INFO] ------------------------------------------------------------------------
[INFO] [INFO] Total time:  1.878 s
[INFO] [INFO] Finished at: 2022-05-20T14:29:16+02:00
[INFO] [INFO] ------------------------------------------------------------------------
[INFO] [prepare] 11/17 scm-commit-release
[INFO] Checking in modified POMs...
[INFO] Executing: /bin/sh -c cd '/Users/me/code/myproject' && 'git' 'add' '--' 'pom.xml' 'module1/pom.xml' 'module2/pom.xml' 'module3/pom.xml'
[INFO] Working directory: /Users/me/code/myproject
[INFO] Executing: /bin/sh -c cd '/Users/me/code/myproject' && 'git' 'rev-parse' '--show-prefix'
[INFO] Working directory: /Users/me/code/myproject
[INFO] Executing: /bin/sh -c cd '/Users/me/code/myproject' && 'git' 'status' '--porcelain' '.'
[INFO] Working directory: /Users/me/code/myproject
[WARNING] Ignoring unrecognized line: ?? module1/pom.xml.releaseBackup
[WARNING] Ignoring unrecognized line: ?? module2/pom.xml.releaseBackup
[WARNING] Ignoring unrecognized line: ?? pom.xml.releaseBackup
[WARNING] Ignoring unrecognized line: ?? release.properties
[WARNING] Ignoring unrecognized line: ?? module3/pom.xml.releaseBackup
[INFO] Executing: /bin/sh -c cd '/Users/me/code/myproject' && 'git' 'commit' '--verbose' '-F' '/var/folders/xb/pl4xth9n5qbgksbyy2fy5lm80000gn/T/maven-scm-1737591658.commit'
[INFO] Working directory: /Users/me/code/myproject
[INFO] Executing: /bin/sh -c cd '/Users/me/code/myproject' && 'git' 'symbolic-ref' 'HEAD'
[INFO] Working directory: /Users/me/code/myproject
[INFO] Executing: /bin/sh -c cd '/Users/me/code/myproject' && 'git' 'push' 'ssh:********@github.com/company/myproject.git' 'refs/heads/main:refs/heads/main'
[INFO] Working directory: /Users/me/code/myproject
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary for myproject-base 3.0.1-SNAPSHOT:
[INFO] 
[INFO] myproject-base ........................................ FAILURE [  8.100 s]
[INFO] module1 ............................................... SKIPPED
[INFO] module2 ............................................... SKIPPED
[INFO] module3 ............................................... SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  8.207 s
[INFO] Finished at: 2022-05-20T14:29:18+02:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-release-plugin:3.0.0-M5:prepare (default-cli) on project myproject: Unable to commit files
[ERROR] Provider message:
[ERROR] The git-push command failed.
[ERROR] Command output:
[ERROR] To ssh://github.com/company/myproject.git
[ERROR]  ! [rejected]        main -> main (non-fast-forward)
[ERROR] error: failed to push some refs to 'ssh://github.com/company/myproject.git'
[ERROR] hint: Updates were rejected because the tip of your current branch is behind
[ERROR] hint: its remote counterpart. Integrate the remote changes (e.g.
[ERROR] hint: 'git pull ...') before pushing again.
[ERROR] hint: See the 'Note about fast-forwards' in 'git push --help' for details.
[ERROR] 
[ERROR] -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException

我可以通过使用git command从命令行推动(和拉)。 。我尝试过不同版本的maven-release-plugin无用。我什至删除了整个GitHub存储库,并将其再次从本地机器中推开,但是我仍然遇到同样的错误。是什么造成这一点?

I've spent hours trying to release a project to github with Maven. This is usually not a problem but for some reason it is for this project and I don't understand why. I'm using Maven 3.8.5 with Java 1.8.0_312 and git 2.36.1. Here's the pom.xml file:

<?xml version="1.0" encoding="UTF-8"?>

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>se.company.myproject</groupId>
    <artifactId>myproject</artifactId>
    <version>4.0.0</version>
    <packaging>pom</packaging>

    <name>myproject-base</name>
    <!-- FIXME change it to the project's website -->
    <url>http://www.example.com</url>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <java.version>1.8</java.version>
        <slf4j.version>1.7.36</slf4j.version>
    </properties>

    <modules>
        <module>module1</module>
        <module>module2</module>
        <module>module3</module>
    </modules>

    <scm>
        <connection>scm:git:ssh://[email protected]/mycompany/myproject.git</connection>
        <developerConnection>scm:git:ssh://[email protected]/mycompany/myproject.git</developerConnection>
        <url>https://github.com/mycompany/myproject.git</url>
        <tag>4.0.0</tag>
    </scm>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.slf4j</groupId>
                <artifactId>slf4j-api</artifactId>
                <version>${slf4j.version}</version>
            </dependency>
            <dependency>
                <groupId>se.company.myproject</groupId>
                <artifactId>some-internal-dependency</artifactId>
                <version>5.0.1</version>
            </dependency>
            <!-- Test dependencies -->
            <dependency>
                <groupId>org.assertj</groupId>
                <artifactId>assertj-core</artifactId>
                <version>3.9.1</version>
            </dependency>
            <dependency>
                <groupId>junit</groupId>
                <artifactId>junit</artifactId>
                <version>4.13.2</version>
            </dependency>
            <dependency>
                <groupId>org.slf4j</groupId>
                <artifactId>slf4j-log4j12</artifactId>
                <version>${slf4j.version}</version>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.10.1</version>
                <configuration>
                    <source>${java.version}</source>
                    <target>${java.version}</target>
                    <encoding>${project.build.sourceEncoding}</encoding>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-release-plugin</artifactId>
                <version>3.0.0-M5</version>
                <configuration>
                    <tagNameFormat>@{project.version}</tagNameFormat>
                    <autoVersionSubmodules>true</autoVersionSubmodules>
                </configuration>
            </plugin>
        </plugins>
    </build>


    <distributionManagement>
        <repository>
            <id>company-releases</id>
            <name>Internal Releases</name>
            <url>https://company.se/company-maven-releases/</url>
        </repository>
        <snapshotRepository>
            <id>company-snapshots</id>
            <name>Internal Snapshots</name>
            <url>https://company.se/company-maven-snapshots/</url>
        </snapshotRepository>
    </distributionManagement>

    <repositories>
        <repository>
            <id>company-releases</id>
            <url>https://company.se/company-maven-releases/</url>
        </repository>
    </repositories>
</project>

When I run maven release:prepare I get this:

[INFO] [INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ myproject-module3 ---
[INFO] [INFO] Building jar: /Users/me/code/module3/target/myproject-module3-4.0.0.jar
[INFO] [INFO] ------------------------------------------------------------------------
[INFO] [INFO] Reactor Summary for myproject-base 4.0.0:
[INFO] [INFO] 
[INFO] [INFO] myproject-base ..................................... SUCCESS [  0.059 s]
[INFO] [INFO] module1............................................. SUCCESS [  1.097 s]
[INFO] [INFO] module2 ............................................ SUCCESS [  0.603 s]
[INFO] [INFO] module3 ............................................ SUCCESS [  0.046 s]
[INFO] [INFO] ------------------------------------------------------------------------
[INFO] [INFO] BUILD SUCCESS
[INFO] [INFO] ------------------------------------------------------------------------
[INFO] [INFO] Total time:  1.878 s
[INFO] [INFO] Finished at: 2022-05-20T14:29:16+02:00
[INFO] [INFO] ------------------------------------------------------------------------
[INFO] [prepare] 11/17 scm-commit-release
[INFO] Checking in modified POMs...
[INFO] Executing: /bin/sh -c cd '/Users/me/code/myproject' && 'git' 'add' '--' 'pom.xml' 'module1/pom.xml' 'module2/pom.xml' 'module3/pom.xml'
[INFO] Working directory: /Users/me/code/myproject
[INFO] Executing: /bin/sh -c cd '/Users/me/code/myproject' && 'git' 'rev-parse' '--show-prefix'
[INFO] Working directory: /Users/me/code/myproject
[INFO] Executing: /bin/sh -c cd '/Users/me/code/myproject' && 'git' 'status' '--porcelain' '.'
[INFO] Working directory: /Users/me/code/myproject
[WARNING] Ignoring unrecognized line: ?? module1/pom.xml.releaseBackup
[WARNING] Ignoring unrecognized line: ?? module2/pom.xml.releaseBackup
[WARNING] Ignoring unrecognized line: ?? pom.xml.releaseBackup
[WARNING] Ignoring unrecognized line: ?? release.properties
[WARNING] Ignoring unrecognized line: ?? module3/pom.xml.releaseBackup
[INFO] Executing: /bin/sh -c cd '/Users/me/code/myproject' && 'git' 'commit' '--verbose' '-F' '/var/folders/xb/pl4xth9n5qbgksbyy2fy5lm80000gn/T/maven-scm-1737591658.commit'
[INFO] Working directory: /Users/me/code/myproject
[INFO] Executing: /bin/sh -c cd '/Users/me/code/myproject' && 'git' 'symbolic-ref' 'HEAD'
[INFO] Working directory: /Users/me/code/myproject
[INFO] Executing: /bin/sh -c cd '/Users/me/code/myproject' && 'git' 'push' 'ssh:********@github.com/company/myproject.git' 'refs/heads/main:refs/heads/main'
[INFO] Working directory: /Users/me/code/myproject
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary for myproject-base 3.0.1-SNAPSHOT:
[INFO] 
[INFO] myproject-base ........................................ FAILURE [  8.100 s]
[INFO] module1 ............................................... SKIPPED
[INFO] module2 ............................................... SKIPPED
[INFO] module3 ............................................... SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  8.207 s
[INFO] Finished at: 2022-05-20T14:29:18+02:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-release-plugin:3.0.0-M5:prepare (default-cli) on project myproject: Unable to commit files
[ERROR] Provider message:
[ERROR] The git-push command failed.
[ERROR] Command output:
[ERROR] To ssh://github.com/company/myproject.git
[ERROR]  ! [rejected]        main -> main (non-fast-forward)
[ERROR] error: failed to push some refs to 'ssh://github.com/company/myproject.git'
[ERROR] hint: Updates were rejected because the tip of your current branch is behind
[ERROR] hint: its remote counterpart. Integrate the remote changes (e.g.
[ERROR] hint: 'git pull ...') before pushing again.
[ERROR] hint: See the 'Note about fast-forwards' in 'git push --help' for details.
[ERROR] 
[ERROR] -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException

I can push (and pull) just fine from the command line by using the git command. I've tried different versions of the maven-release-plugin to no avail. I've even deleted the entire GitHub repository and pushed it again from my local machine but still, I get the same error. What could be causing this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

惟欲睡 2025-02-06 15:38:34

MVN -X准备应向您展示从您的git:ssh:// [email&nbsp; procearted] /mymycompany/myproject.git.git

将其与最新的提交在github上相提并论。

尝试使用exec目标进行 git lupl git plup mvn发布 是可能的,但是最好首先确定为什么您没有本地没有的远程提交。

A mvn -X prepare should show you which commit is checked out from your git:ssh://[email protected]/mycompany/myproject.git

Compare it with the latest commit on GitHub to understand the difference.

Trying to use an exec goal to do a git pull before mvn release is possible, but it is better to identify first why there is a remote commit that you do not have locally.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文