无法推送到git

时间:2016-04-12 11:38:55

标签: git github github-api

当我试图推动掌握即时错误

  

https://github.my.corp/i64444/app.git! [拒绝]
  HEAD - > refs / for / master(非快进)错误:无法推送一些   引用'https://github.my.corp/i64444/app.git'提示:   更新被拒绝,因为推送的分支提示在其远程后面   暗示:对口。查看此分支并集成远程   在再次推送之前改变提示:(例如'git pull ...')。提示:见   有关详细信息,请参阅'git push --help'中的'关于快进的说明'。

我阅读了以下帖子 Cannot push to GitHub - keeps saying need merge 并尝试做 git push -f origin master 哪个没有帮助,我得到消息说每个都是最新的,任何想法?

我也在git reset之前做过--hard origin master(fetch& rebase)也没有帮助......,任何想法?

拉动

的输出
 * branch            master     -> FETCH_HEAD
Already up-to-date.

git状态的输出是:

HEAD detached from ea82585
Untracked files:
  (use "git add <file>..." to include in what will be committed)

        .idea/

nothing added to commit but untracked files present (use "git add" to track)

数字 ea82585 是主数据中最新提交的编号...

1 个答案:

答案 0 :(得分:2)

git status输出:

  

HEAD脱离了ea82585

您似乎已经签出了提交而不是分支。因此git无法跟踪您对远程分支的当前提交。一旦你进入所谓的分离的头状态,git将被卡在提交中,因此当你拉或推时它什么都不做。 Check out this answer了解有关分离头的详细信息。

如果git能够跟踪您的远程存储库的本地分支,您将看到git status输出如下:

$ git status 
On branch dev 
Your branch is up-to-date with 'origin/dev'.

如何修复

基本上,您必须将提交移动到Git可以跟踪的分支。您可以通过以下方式执行此操作:

git commit -m "....."
git branch my-temporary-work
git checkout master
git merge my-temporary-work

从此answer

复制