It happened when I tried to deploy to Heroku by typing the git push heroku master
command.
Terminal
% git push heroku master
To https://git.heroku.com/~~.git
![rejected] master -> master (non-fast-forward)
error: failed to push some refs to 'https://git.heroku.com/~~.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.
The points are rejected
, non-fast-forward
, hint
.
In conclusion, it was an error that occurred because there was no difference (state) between Heroku and the local commit. It seems that Heroku was more committed.
One of the following solutions was considered! Simply put, git pull heroku master
matches Heroku's state locally, and git pull origin master
reflects the remote state locally to match the remote state with the local state. think.
The bottom line is to keep your remote, local, and Heroku (post-deployment) states up to date.
This time I solved it with git pull heroku master
!
% git pull origin master
% git pull heroku master
First of all, what kind of situation is this error? rejected
means that the deployment is rejected. They are politely giving out hint
, so it seems that you can solve it if you understand each one. Also, it is an error statement that non-fast-forward
cannot be pushed because it has already been pushed.
I was basically deploying from the master branch, so I did `git commit --allow-empty -m" empty commit "`
and then `` `git push heroku master``` It was. You may have created a new working branch in that state by doing an undo or revert after doing an empty commit. ..
Also, I think it is effective to look at the Heroku log and see the error statement.
Terminal
% heroku logs --tail --app app name
If you pay attention to the first sentence of hint
hint
Updates were rejected because the tip of your current branch is behind
Translated literally *** The update was rejected because the tip of the current branch is behind. ***is what it means. Does that mean that there is a gap or difference in commit? ..
I got an error with git push heroku master
, so I thought about the following two things.
- There is a difference between remote and local.
Terminal
% git pull origin master
warning: Pulling without specifying how to reconcile divergent branches is
discouraged. You can squelch this message by running one of the following
commands sometime before your next pull:
git config pull.rebase false # merge (the default strategy)
git config pull.rebase true # rebase
git config pull.ff only # fast-forward only
You can replace "git config" with "git config --global" to set a default
preference for all repositories. You can also pass --rebase, --no-rebase,
or --ff-only on the command line to override the configured default per
invocation.
From https://github.com/~~
* branch master -> FETCH_HEAD
Already up to date.
Already up to date!
Is already up to date. (Or maybe it was up to date)
After that, I tried git push heroku master
, but the same error occurred without any particular change, so next.
- There is a local difference with Heroku.
% git pull heroku master
warning: Pulling without specifying how to reconcile divergent branches is
discouraged. You can squelch this message by running one of the following
commands sometime before your next pull:
git config pull.rebase false # merge (the default strategy)
git config pull.rebase true # rebase
git config pull.ff only # fast-forward only
You can replace "git config" with "git config --global" to set a default
preference for all repositories. You can also pass --rebase, --no-rebase,
or --ff-only on the command line to override the configured default per
invocation.
From https://git.heroku.com/~~
* branch master -> FETCH_HEAD
Already up to date!
Merge made by the 'recursive' strategy.
The points I think are the points are described below.
Already up to date!
Merge made by the 'recursive' strategy.
It seems that it merged automatically, so I checked GitHub Desktop! It seems that past commits have been merged and the diff has disappeared.
After confirmation, the deployment was completed with git push heroku master
.
--Keep the local and remote repositories up-to-date and then deploy. ――Undo and Revert are useful functions, but you should think about what happens when you use them. --If there is a hint in the error statement, it will be resolved quickly if you read it, and the application may be effective even if the next error occurs.
http://shoprev.hatenablog.com/entry/2014/07/31/200540 https://qiita.com/taka_no_okapi/items/0444afde4817920d0671 https://qiita.com/nasutaro211/items/c590994a5d5091206c08
Recommended Posts