Git 使用 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 拉动时,我得到以下信息:
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 的代码,但有没有想过为什么它仍然会出错?
编辑2:
运行 git pull heroku master 产量:
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.
你需要运行
git pull heroku_app_name master
希望有用。
如果您确定自己在做什么,可以强制推送到 heroku:
git push --force heroku master
这意味着您存储库中的代码比本地存储库中的代码更新。
您必须在本地合并您的更改:
git pull heroku master
然后你推:
git push heroku master
编辑(根据您的编辑):
尝试git fetch origin
git pull --rebase
再推
以下是最终对我有用的东西:
我登录了我的 heroku 帐户并转到 'Deploy' 选项卡。此处有一个 'Connect to GitHub' 选项,可让您手动 link 这两个帐户。在帐户 linked 之后,您可以在 heroku 帐户上搜索 GitHub 存储库。 link 编辑后,我选择了 'manual deploy' 选项。自此手动部署以来,我已经能够毫无问题地使用 git push heroku master。
如果您使用过
- 捆绑安装 - 没有生产
并没有做
- git commit -am "installed using bundle"
那你遇到这种问题的可能性就更大了。
如果您已经运行
-bundle install--没有生产
然后按照以下步骤解决问题:
- 打开您的 Gemfile 并将您的 Ruby 版本放入其中:
- ruby '2.2.1'
- $ git commit -am "updated the Gemfile"
- $ git 推送 heroku 大师
这解决了问题。
当我尝试 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 拉动时,我得到以下信息:
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 的代码,但有没有想过为什么它仍然会出错?
编辑2:
运行 git pull heroku master 产量:
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.
你需要运行
git pull heroku_app_name master
希望有用。
如果您确定自己在做什么,可以强制推送到 heroku:
git push --force heroku master
这意味着您存储库中的代码比本地存储库中的代码更新。 您必须在本地合并您的更改:
git pull heroku master
然后你推:
git push heroku master
编辑(根据您的编辑):
尝试git fetch origin
git pull --rebase
再推
以下是最终对我有用的东西:
我登录了我的 heroku 帐户并转到 'Deploy' 选项卡。此处有一个 'Connect to GitHub' 选项,可让您手动 link 这两个帐户。在帐户 linked 之后,您可以在 heroku 帐户上搜索 GitHub 存储库。 link 编辑后,我选择了 'manual deploy' 选项。自此手动部署以来,我已经能够毫无问题地使用 git push heroku master。
如果您使用过 - 捆绑安装 - 没有生产 并没有做 - git commit -am "installed using bundle"
那你遇到这种问题的可能性就更大了。
如果您已经运行 -bundle install--没有生产 然后按照以下步骤解决问题:
- 打开您的 Gemfile 并将您的 Ruby 版本放入其中:
- ruby '2.2.1'
- $ git commit -am "updated the Gemfile"
- $ git 推送 heroku 大师
这解决了问题。