【问题标题】:What can I do when git push fails with ..."local out of date"?当 git push 因 ...“本地过期”而失败时,我该怎么办?
【发布时间】:2011-05-13 06:23:44
【问题描述】:

我确信这是一个很容易解决的问题,但我不确定为什么我推送到 GitHub 失败了。

现在看起来像:

$ git push origin master
To git@github.com:user_name/project_name.git
 ! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to 'git@github.com:user_name/project_name.git'
To prevent you from losing history, non-fast-forward updates were rejected
Merge the remote changes before pushing again.  See the 'Note about
fast-forwards' section of 'git push --help' for details.

还有:

$ git remote show origin
* remote origin
  Fetch URL: git@github.com:user_name/project_name.git
  Push  URL: git@github.com:user_name/project_name.git
  HEAD branch: master
  Remote branch:
    master tracked
  Local ref configured for 'git push':
    master pushes to master (local out of date)

另外,当我尝试 git pull 时:

$ git pull
You asked me to pull without telling me which branch you
want to merge with, and 'branch.master.merge' in
your configuration file does not tell me, either. Please
specify which branch you want to use on the command line and
try again (e.g. 'git pull <repository> <refspec>').
See git-pull(1) for details.

If you often merge with the same branch, you may want to
use something like the following in your configuration file:

    [branch "master"]
    remote = <nickname>
    merge = <remote-ref>

    [remote "<nickname>"]
    url = <url>
    fetch = <refspec>

See git-config(1) for details.

我做了什么导致这种状态......我应该怎么做才能修复它?

【问题讨论】:

    标签: git github git-push git-pull git-remote


    【解决方案1】:

    从远程拉取

    git pull origin master
    

    【讨论】:

      猜你喜欢
      • 2010-09-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-06-28
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多