无法Git从天青管道推送到远程分支(不是主节点)

时间:2019-06-12 16:49:12

标签: bash git github azure-devops

我一直在尝试通过Azure DevOps上的bash任务执行Git Push。我已经将代码推送到master分支了,没有任何问题。 但是现在我必须将其推送到dev分支,由于某种原因,Git Pull可以运行,但Git Push不能。这些是我遵循的步骤。我实际上尝试了各种版本,但没有任何效果。

thufir@dur:~/java/wildfly$ 
thufir@dur:~/java/wildfly$ tree wildfly-17.0.0.Beta1  | grep wildflyMaps.war
│       └── wildflyMaps.war
thufir@dur:~/java/wildfly$ 

当推/拉末尾有HEAD:master时,上述方法起作用。 这是我每次都遇到的错误。

git config --global user.email "xxx@gmail.com"
git config --global user.name "abc"

git pull https://PAT@github.com/repo.git HEAD:dev    
git add $PROXYNAME
git commit -m 'Auto-checkin of $PROXYNAME proxy to Git'
git show-ref
git push https://PAT@github.com/repo.git HEAD:dev

编辑后添加: 我也尝试过使用checkout命令-签出该dev分支,没有运气! git remote -v的结果:

To https://github.com/repo.git
 ! [rejected]        HEAD -> dev (non-fast-forward)
error: failed to push some refs to 'https://***@github.com/repo.git'
hint: Updates were rejected because a pushed branch tip is behind its remote
hint: counterpart. Check out this branch and integrate the remote changes
hint: (e.g. 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

1 个答案:

答案 0 :(得分:0)

我相信您需要将git remote配置为正确的存储库。

git remote -v的结果应引用您当前的目录远程关联。

git remote --help

开头

特别是:

  

git remote set-url [--push] [] git remote

     

set-url --add [--push]

tutorial on git remote很好。