簡體   English   中英

用Rails推送Heroku Master錯誤

[英]Git Push Heroku Master error with Rails

當我嘗試git push heroku master命令時,我收到以下錯誤:

matt@matt-desktop:~/Documents/Ruby/rails_projects/ninja_speak_app$ git push heroku master
To https://git.heroku.com/limitless-inlet-4477.git
 ! [rejected]        master -> master (fetch first)
error: failed to push some refs to 'https://git.heroku.com/limitless-inlet-4477.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.

這個存儲庫昨天在github上建立,名為ninja_speak_app。 在設置存儲庫時,我小心不要使用自述文件或許可證進行初始化。

當我做一個git pull我得到以下內容:

matt@matt-desktop:~/Documents/Ruby/rails_projects/ninja_speak_app$ git pull
Already up-to-date.

提交還顯示一切都是最新的:

matt@matt-desktop:~/Documents/Ruby/rails_projects/ninja_speak_app$ git commit -m "first commit"
On branch master
Your branch is up-to-date with 'origin/master'.

nothing to commit, working directory clean

編輯:運行git push --force heroku master產生以下結果:

matt@matt-desktop:~/Documents/Ruby/rails_projects/ninja_speak_app$ git push --force heroku master
Counting objects: 25701, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (25297/25297), done.
Writing objects: 100% (25701/25701), 104.98 MiB | 97.00 KiB/s, done.
Total 25701 (delta 322), reused 25668 (delta 309)
remote: Compressing source files... done.
remote: Building source:
remote: 
remote: Build stream timed out, reverting to polling....
remote: !   Timeout reached polling for results.
remote: 
To https://git.heroku.com/limitless-inlet-4477.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/limitless-inlet-4477.git'

我可以使用--force獲取代碼到heroku,但任何想法為什么它仍然出錯?

EDIT2:

運行git pull heroku master yield:

matt@matt-desktop:~/Documents/Ruby/rails_projects/ninja_speak_app$ git pull heroku master
warning: no common commits
remote: Counting objects: 69191, done.
remote: Compressing objects: 100% (45212/45212), done.
remote: Total 69191 (delta 17653), reused 68275 (delta 16751)
Receiving objects: 100% (69191/69191), 129.00 MiB | 884.00 KiB/s, done.
Resolving deltas: 100% (17653/17653), done.
From https://git.heroku.com/limitless-inlet-4477
 * branch            master     -> FETCH_HEAD
 * [new branch]      master     -> heroku/master
Auto packing the repository for optimum performance. You may also
run "git gc" manually. See "git help gc" for more information.
Counting objects: 673, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (594/594), done.
Writing objects: 100% (673/673), done.
Total 673 (delta 239), reused 0 (delta 0)
error: The following untracked working tree files would be overwritten by merge:
    db/development.sqlite3
    db/production.sqlite3
    db/test.sqlite3
    log/development.log
    log/production.log
    log/test.log
    tmp/cache/assets/C12/AE0/sprockets%2Fc558458ba9671201141a50f2240184c9
    ...
    ...
Aborting

Git push heroku master然后產生:

matt@matt-desktop:~/Documents/Ruby/rails_projects/ninja_speak_app$ git push heroku master
To https://git.heroku.com/limitless-inlet-4477.git
 ! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to 'https://git.heroku.com/limitless-inlet-4477.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

如果您確定自己在做什么,可以強制推送到heroku:

git push --force heroku master

這意味着您的存儲庫中的代碼比本地存儲庫中的代碼更新。 您必須在本地合並您的更改:

git pull heroku master

然后你推:

git push heroku master

編輯(編輯后):

嘗試git fetch origin

git pull --rebase

再推一次

以下是最終為我工作的內容:

我登錄了我的heroku帳戶並轉到了“部署”標簽。 從這里有一個'Connect to GitHub'選項,允許您手動鏈接這兩個帳戶。 鏈接帳戶后,您可以在heroku帳戶上搜索GitHub倉庫。 鏈接后,我選擇了“手動部署”選項。 自從手動部署以來,我已經能夠毫無問題地使用git push heroku master。

你需要跑

git pull heroku_app_name master

希望它有效。

如果您已經使用 - bundle install - 沒有生產而沒有 - git commit -am“使用bundle安裝”

那么你更有可能面臨這樣的問題。

如果您已經運行-bundle install - 沒有生產,請按照以下步驟操作,您可以解決此問題:

  1. 打開你的Gemfile並將你的Ruby版本放入其中:
    • 紅寶石'2.2.1'
  2. $ git commit -am“更新了Gemfile”
  3. $ git push heroku master

這解決了這個問題。

暫無
暫無

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

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