尝试推送一个提交时git错误

时间:2013-07-10 18:49:10

标签: git push commit

我正在尝试将一个提交推送到origin master。但是我得到一个错误,说我首先需要获取然后合并,但是在拉动之后我得到了这个错误。任何想法都将不胜感激。

Richard@RICHARD-PC /e/Work/MH (master)
$ git pull
remote: Counting objects: 27, done.
remote: Compressing objects: 100% (11/11), done.
remote: Total 14 (delta 8), reused 0 (delta 0)
Unpacking objects: 100% (14/14), done.
From file:///V:\
   930430f..3a55dca  master     -> origin/master
Auto-merging project/src/main/java/com/company/project/outgoing/HttpsCallService.java
Merge made by the 'recursive' strategy.
 .../java/com/company/project/auth/BcagHmacGenerator.java  |  2 +-
 .../com/company/project/outgoing/HttpsCallService.java    | 16 ++--------------
 deployLocal.sh                                           |  2 +-
 3 files changed, 4 insertions(+), 16 deletions(-)

Richard@RICHARD-PC /e/Work/MH (master)
$ git push origin 72ba712:master
To file:///V:\
 ! [rejected]        72ba712 -> master (non-fast-forward)
error: failed to push some refs to 'file:///V:\'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Merge the remote changes (e.g. 'git pull')
hint: before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

以下是提交列表,而不是72ba712的位置:

Richard@RICHARD-PC /e/Work/MH (master)
$ git lol
*   eec2ab2 (HEAD, master) Merge branch 'master' of file:///V:\
|\
| * 3a55dca (origin/master) <comments>
* | 72ba712 <comments>
* | bc55eb5 <comments>
* |   c2aa448 Merge branch 'master' of file:///V:\
|\ \
| |/
| * 930430f <comments>
* | fc7a55b <comments>
* | fd401a5 <comments>

2 个答案:

答案 0 :(得分:0)

这不是错误,您在master上提交的是您自己的提交。为了确保您实际上是最新的,请按照以下步骤进行拉动:

git fetch origin
#then....
git pull origin master

这将确保您从正确的位置拉出,然后您可以按照以下方式推送您提交的更改(再次明确,以便git知道将要发生的事情):

git push origin master

您的错误可能来自您的语法,您可能已经在某些内容中配置了git,这使得您现在提取的方式git pull对git不明确。

答案 1 :(得分:0)

您正尝试将带有hashvalue 72ba712的提交推送到远程主分支,但这显然不起作用,没有合并,您已经做了什么。现在,在合并之后,您必须推送合并提交:

git push origin eec2ab2:master

或更容易:

git push origin HEAD:master