无法推送到git存储库

时间:2018-01-29 14:38:04

标签: git

我正在尝试推送我的项目,但因为错误被拒绝,而我无法理解错误。

$ git push origin master
To https://github.com/sunil887/Angular2App.git
 ! [rejected]        master -> master (fetch first)
error: failed to push some refs to 'https://github.com/sunil887/Angular2App.git'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first 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.

5 个答案:

答案 0 :(得分:0)

在尝试推送之前执行git pull。这应该可以解决问题,也可以提供有关导致问题的更多信息。

答案 1 :(得分:0)

看起来你需要

git pull 

第一

您的遥控器包含本地计算机上不存在的更改。

如果这个

答案 2 :(得分:0)

以下是您需要考虑可能的merge conflict的分步过程。

  1. 执行git pull更新本地存储库。
  2. 执行merge conflict后可能会有git pull,您会在终端中看到此信息。如果发生这种情况,请检查哪些文件与git status冲突。
  3. 修复merge conflicts(如果有)后,您现在可以继续使用git add -Agit commit -m [commit message]
  4. 添加和提交您的本地更改
  5. 最后,做一个git push [upstream] [branch]

答案 3 :(得分:0)

检查您的远程git。您的更改可能已经存在。

答案 4 :(得分:-2)

我遇到了同样的问题:

Image of command prompt

并且,为了摆脱错误:

您不应该使用 git push origin master。但是,您应该使用 git push origin main