当前位置:  开发笔记 > 开发工具 > 正文

当git push失败并且......"本地过时"时,我该怎么办?

如何解决《当gitpush失败并且"本地过时"时,我该怎么办?》经验,为你挑选了1个好方法。

我确信这是一个非常简单的解决方案,但我不确定为什么我推送到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  ').
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 = 
    merge = 

    [remote ""]
    url = 
    fetch = 

See git-config(1) for details.

我做了什么来引起这种状态......我该怎么做才能解决这个问题?



1> Chandra Patn..:

从远程拉

git pull origin master

推荐阅读
黄晓敏3023
这个屌丝很懒,什么也没留下!
DevBox开发工具箱 | 专业的在线开发工具网站    京公网安备 11010802040832号  |  京ICP备19059560号-6
Copyright © 1998 - 2020 DevBox.CN. All Rights Reserved devBox.cn 开发工具箱 版权所有