Git remote keeps getting rejected when pushing to heroku - spring

I am currently learning Git and Heroku.
I'm at the point where I have created a Spring Boot project, initialized Git, and created an application on Heroku.
Now when I add all files, everything works. I commit the changes, no flaws, and lastly I set-up a remote to my .git.
This is where my error occurs. When I push my project onto my git, I get an error saying:
To https://git.heroku.com/heroku-boottest.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/heroku-boottest.git'
Keep in mind that my git is empty. I haven't pushed anything else onto the git.
Thanks in advance!

I solved my issue!
For some reason heroku didn't want me to use JDK 14, so I changed my pom.xml to jdk 8

Based on the answer from here.
If the GitHub repo has seen new commits pushed to it, while you were
working locally, I would advise using:
git pull --rebase
git push

Related

How to update a website deployed on heroku?

I created a website that I deployed on heroku. I have made some changes there and am looking to update my website to reflect these changes. To do this, I ran the following commands:
git status
git init
git status
git remote -v
git add .
git commit -m"The file"
git push heroku masterbranch
I want to clarify that the masterbranch branch is a branch that has been created. The base branch of my website is master not masterbranch. The reason why, I created a new branch is that when I ran the command: git push heroku master I was getting the error:error: failed to push some refs to 'https://git.heroku.com/gkwhelps.git' But I don't think that is the reason why my deployed site does not is not up to date.
This has nothing to do with Git itself. See the heroku documentation, which notes that:
Heroku only deploys code that you push to the master or main branches of the remote. Pushing code to another branch of the heroku remote has no effect.
You mention:
when I ran the command: git push heroku master I was getting the error: error: failed to push some refs to 'https://git.heroku.com/gkwhelps.git'
When you push to the main or master branch, Heroku will:
read your code;
attempt to build your code based on what it read in step 1;
attempt to deploy your build from step 3.
Any of these three steps can have errors. If they do have errors, Heroku uses Git to relay these errors to you and then tells Git to produce the above error message. So Git says that your push failed, but that's because Heroku told Git to fail it. You cannot fix this problem by creating another branch. You must address the problems that occurred in steps 1, 2, and/or 3.
If you first push your code on Github and from Github do deploy, you shoud do:
git status
git add .
git commit -m 'changes'
git push
After that you should connect Heroku with Github and do deploy from that branch from Github.

Getting an error while trying to pull git Xcode

I am working with a colleague on a project in Xcode. He committed and pushed some changes. Before fetching and refreshing status, I committed and pushed my changes too...
What I've tried so far:
To pull and rebase local changes onto upstream changes.
Then I stash and pull. But get "An unknown error occurred".
So, basically my git has these arrows down and up:
Xcode. Git situation
Since it's an important project, I don't know if I should do a force push.. Any ideas on how I can resolve it correctly?
UPDATE:
I tried writing git pull in Console and here is what I've got:
error: The following untracked working tree files would be overwritten by merge:
And this is the message I get when I try to git push:
! [rejected] branch -> branch (non-fast-forward)
error: failed to push some refs to 'git#gitlab.com:***'

Heroku can't find package.json during build although I have it

When I push my node app to heroku master I get this log
remote: Building source:
remote:
remote: -----> App not compatible with buildpack: https://codon-
buildpacks.s3.amazonaws.com/buildpacks/heroku/nodejs.tgz
remote: Node.js: package.json not found in application root
I can't find the reason why this would happen as I clearly have in my root directory. I checked using git ls-files and it appears.
Is it possible that my application root is not the same as my repository root? How would one config that?
It seems that when I push to heroku master, heroku pushes the main branch of my local repository to heroku instead of the branch I'm currently in. So what I had to do was pushing with:
git push heroku mybranchname:master
so that my branch (not the master) gets pushed
One common issue is not having added the files to git.
You might be having package.json in your root directory on you device, without adding it to git, heroku can't find it.
Please check status to confirm and add if not added already
git status
git add .
then followed by the usual
git push heroku master assuming you are on the master branch.
Hope this helps.
I think just pushing a branch and not the master should fix it. If you do not have a branch, I suggest you create one and push with that.

Getting error when trying to git push to remote branch (Heroku)

Hi I tried to push my local changes to heroku production but I am getting the following error
Zhens-MacBook-Pro:Dailymuses-Server-Side zaikshev88$ git push heroku-production master:master
To git#heroku.com:dailymuses.git
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to 'git#heroku.com:dailymuses.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Merge the remote changes (e.g. 'git pull')
hint: before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
The issue here is that when I tried to do a git pull, I was told that everything is up to date
Zhens-MacBook-Pro:Dailymuses-Server-Side zaikshev88$ git pull origin master
From github.com:mingyeow/Dailymuses-Server-Side
* branch master -> FETCH_HEAD
Already up-to-date.
What is the issue here and how can I resolve it?
Your push command is to remote heroku-production but your pull command is to origin. The non-fast-foward message means the history in your current repo differs from the Heroku remote; likely someone has pushed a branch with some merges or rebases.
I implore you to not use Heroku as the authoritative git remote. Assuming you are not, you can force push over the Heroku master branch to resolve this.
git push -f heroku-production master:master

"Heroku push rejected, no Cedar-supported app detected" when trying to upload a Sinatra app with an existing git repo

I have an existing git repo for my personal website, which I am porting to Sinatra (mainly for templating, it's a static site). I do NOT want to lose/reset this git repository.
When I try to push to Heroku, I get the error below. I have a config.ru file, a Gemfile, and a Gemfile.lock, along with some other stuff for Sinatra. Running rackup works, running bundle exec rackup works, and I didn't get any warnings from Heroku about missing dependencies.
Am I missing something? I can post the directory structure of my site if it would help (though it's close sourced).
~/Repos/website ➜ gp heroku master
Counting objects: 2836, done.
Compressing objects: 100% (2669/2669), done.
Writing objects: 100% (2836/2836), 3.48 MiB | 252 KiB/s, done.
Total 2836 (delta 481), reused 2117 (delta 155)
-----> Heroku receiving push
! Heroku push rejected, no Cedar-supported app detected
To git#heroku.com:APP_NAME_HERE.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'git#heroku.com:APP_NAME_HERE.git'
A Cedar app should recognise the config.ru file and create a web process for you, so it's possible that some essential file is not tracked by git. Check that config.ru, Gemfile and Gemfile.lock are all committed (you can use git status, but note that it will not output anything for ignored files so you should also check your .gitignore file).
If all the files are committed, you could also try specifying the command you want the web process to use in a Procfile. See the Heroku docs for more information:
Getting started with Ruby: Declare process types with Procfile
Declaring and Scaling Process Types with Procfile
Problem solved. I was working on a git branch especially for Heroku/Sinatra support, and it turns out I was running git push heroku master, which pushed local master to remote master. The master branch did not have a valid Heroku app. I assumed it would push the current local branch to the remote master branch, which is not the case. git push sinatra:master solved the issue.
For those who find that the accepted answer doesn't solve their problem, this related question may provide the solution: "Heroku push rejected, no Cedar-supported app detected" when trying to upload a Sinatra app with an existing git repo

Resources