【问题标题】:How do I make git understand that its "push" has failed? Git push failed. Cannot add files to a commit now.我如何让 git 明白它的“推送”失败了? Git 推送失败。现在无法将文件添加到提交。
【发布时间】:2015-04-17 23:09:16
【问题描述】:

我想重新添加、重新提交和重新推送所有内容。 Git 认为它已推送到远程存储库,但不知何故失败了。

以下是我所经历的步骤和结果。 0.在github.com创建远程git仓库 1.git初始化 在我的工作目录中

  1. git add .

  2. git 远程添加源https://github.com/me/myfiles

  3. git push -u origin master -失败。 HTTP 错误(我没有确切的语言)

现在,当我运行“git status”时,我什么也得不到。似乎认为我已经“推送”了所有内容,但它不在 Github 中。

我检查了 .ignore 和 .exclude 文件。

我想重新添加、重新提交和重新推送所有内容。

On branch master
Changes to be committed:
  (use "git reset HEAD <file>..." to unstage)

new file:   Test file/ file

 Changes not staged for commit:
   (use "git add/rm <file>..." to update what will be committed)
   (use "git checkout -- <file>..." to discard changes in working directory)


 Untracked files:
   (use "git add <file>..." to include in what will be committed)
nothing added to commit but untracked files present (use "git add" to track)

【问题讨论】:

  • 再次git push -u origin master
  • 不幸的是,这不起作用。它返回一切都是最新的,但我的 git 文件夹仍然是完全空的。
  • 成功了。我拿出“-u”,现在一切都是最新的。知道为什么这可能是关键吗?

标签: git github git-push


【解决方案1】:

知道为什么这可能是关键吗?

考虑到您在问题中提到的状态,文件未添加到索引中,或者提交未完成(考虑到它在第 2 步和第 3 步之间丢失)

如果第一次提交丢失,您将无法将任何内容推送到远程(push -u 或否):您将推送 0 次提交。

一旦你设法进行了至少一次提交,推送就可以继续。

【讨论】:

  • 听起来像你说的那样,如果我稍后在“git push”上做了一些更改并添加了它们,它将更新所有应该被“推送”的文件即使没有添加那些旧文件(应该已经推送)之前?
  • @Android102 不,重点是提交部分:更改和添加是不够的。您需要至少进行一次提交才能推送任何内容。
猜你喜欢
  • 2011-02-11
  • 2021-10-26
  • 1970-01-01
  • 1970-01-01
  • 2014-10-21
  • 2018-05-02
  • 2014-02-16
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多