簡體   English   中英

提交到github時缺少本地文件

[英]Missing local file when committing to github

在linux命令行中執行一些命令后,在本地存儲庫和github存儲庫中都找不到文件。 這是我使用的命令。

$ git init
$ git config user.name 4everZard
$ git config user.email bryanwu610@gmail.com
$ git add *
$ git commit -m 'First commit'
$ git remote add origin https://github.com/4everZard/pdfeditor
$ git remote -v
$ git push origin master

這是我從終端獲得的信息:

Username for 'https://github.com': 4everZard
Password for 'https://4everZard@github.com': 
To https://github.com/4everZard/pdfeditor
! [rejected]        master -> master (fetch first)
error: failed to push some refs to 'https://github.com/4everZard/pdfeditor'
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.

完成此操作后,我再也找不到文件了。 我對github完全陌生,請幫忙! 謝謝:)

編輯:問題已解決。 這個問題是由於我創建了另一個HEAD,使原頭變成分離頭。 一旦意識到這一點,就創建一個新的臨時HEAD並將其拉回到原始主機,然后一切都解決了。 謝謝大家。
一些鏈接可能有助於解決那些遇到相同問題的鏈接: 如何使分離的HEAD與master / origin協調?
Github“更新被拒絕,因為遠程包含您沒有的工作”

您的存儲庫中似乎有一個默認的README.md文件。 嘗試通過強制推送覆蓋它:

git push --force origin master

請注意,您不需要每次都使用--force ,因為Git將在您的第一個提交之后的后續提交中開始跟蹤關系:)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM