如何修复未能推送一些参考

时间:2019-08-05 12:17:01

标签: git bitbucket git-flow

我在启用了git-glow的bitbucket中有一个工作树,然后在我们的服务器上有远程存储库。我目前正在使用功能分支,然后通过创建拉取请求合并文件。

然后,我在本地存储库中添加了一个合并后脚本,以在拉出develop分支时将更新的文件推回远程。

起初,它按预期工作,但后来进行更多测试时出现此错误。

我试图重新克隆我的本地副本,但仍然在下面出现错误。

合并后

export DEPLOY_BRANCH=$(git rev-parse --symbolic-full-name --abbrev-ref HEAD)

# When receiving a new git push, the received branch gets compared to this one.
# If you do not need this, just add a comment
export DEPLOY_BRANCH_DEV="develop"


if [ "${DEPLOY_BRANCH_DEV}" == "$DEPLOY_BRANCH" ]; then
  git push staging develop
  exit 0
fi

接收后(开发)

#!/bin/bash

DEPLOY_ALLOWED_BRANCH="develop"

while read oldrev newrev refname
do

    BRANCH=$(git rev-parse --symbolic --abbrev-ref $refname)
    NEWREV="$newrev"

    if [ "$DEPLOY_ALLOWED_BRANCH" == "$BRANCH" ]; then
        GIT_WORK_TREE="/var/www/test-git-flow"
        GIT_DIR="/var/www/git/test-git-flow.git"

        echo "***** GIT_DIR: $GIT_DIR"
        echo "***** GIT_WORK_TREE: $GIT_WORK_TREE"

        git checkout -f "${BRANCH}" || exit 1
        git reset --hard "$NEWREV" || exit 1

        exit 0
    fi
done

接收后(主)

#!/bin/bash

DEPLOY_ALLOWED_BRANCH="master"

while read oldrev newrev refname
do

    BRANCH=$(git rev-parse --symbolic --abbrev-ref $refname)
    NEWREV="$newrev"

    if [ "$DEPLOY_ALLOWED_BRANCH" == "$BRANCH" ]; then
        GIT_WORK_TREE="/var/www/test-git-flow"
        GIT_DIR="/var/www/git/test-git-flow.git"

        echo "***** GIT_DIR: $GIT_DIR"
        echo "***** GIT_WORK_TREE: $GIT_WORK_TREE"

        git checkout -f "${BRANCH}" || exit 1
        git reset --hard "$NEWREV" || exit 1

        exit 0
    fi
done

我希望最新的提交会被推送回远程,但是我在下面看到错误:-

! [rejected] develop -> develop (non-fast-forward)
error: failed to push some refs to 'ssh://username@server.com:/var/www/git/test-git-flow.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

每次合并开发时,我都必须在下面运行git命令,然后才能推送到远程,但是我不想每次合并都这样做。

git pull <remote> develop
git push <remote> develop
git reset --hard HEAD~1

不确定什么可能是问题。

0 个答案:

没有答案