Deploying to heroku from git sub directory - node.js

I'm trying to deploy to heroku from a particular directory in my project:
I've tried this command:
git subtree push --prefix output heroku master
and I get the response:
error: failed to push some refs to 'git#heroku.com:intquest.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
Is there a way to --force this command? Or what exactly am I doing wrong?

If you are sure to replace the remote heroku master history with a new one, you can try something similar to this answer:
git push heroku `git subtree split --prefix output master`:master --force

Related

remote: Pushed to branch other than [main, master], skipping build [duplicate]

I have a project hosted on Heroku and it's gotten to the point where I want to make an alternate test server (so I can test Heroku workers without messing up production).
I have already set up my main Heroku remote running my trunk and a Heroku-dev remote on which I wish to run an alternate branch.
My problem is that since my alternate branch isn't master, Heroku won't build it.
$ git push heroku-dev test
counting objects ...
...
Pushed to non-master branch, skipping build.
To git#heroku.com:example-dev.git
* [new branch] test -> test
Switching this build to master is not an option at the moment. Obviously one option is to create a whole new git repo that's a clone of my test branch, but that doesn't sound very ideal.
You can push an alternative branch to Heroku using Git.
git push heroku-dev test:master
This pushes your local test branch to the remote's master branch (on Heroku).
Comment from #Brian Armstrong:
Worth noting also, when you're ready to go back to master you need to do
git push -f heroku master:master
In my case, the default or base branch was develop, so i used:
git push heroku develop:master
In case git push heroku-dev test:master doesn't work for you, try git push heroku test:master.
Remember the "test" in "test:master" is the name of the new branch you are on.
You will need to pull the remote branch first before you can push the non master branch.
Run following command in you local repository
git pull https://heroku:YOUR_HEROKU_API_KEY#git.heroku.com/YOUR_APP_NAME.git

git#gitlab.com: Permission denied (publickey,keyboard-interactive)

I have a Gitlab repository that contain a number of projects on all of which I can pull and push documents to with Git Bash. I want to set up new project. On the Gitlab website I have created the new project and am following the usual instructions in Git Bash:
cd existing_folder
git init
git remote add origin git#gitlab.com:new_project_name.git
git add .
git commit -m "Initial commit"
git push -u origin master
However when I try push (the last line of the above I get the error:
$ git push -u origin master
error: src refspec master does not match any
error: failed to push some refs to 'git#gitlab.com:new_project_name.git'
(NB: the project name has been replace in this post by new_project_name)
There is a readme file that is ready to be committed.
I know I've missed something or done something incorrectly but I don't know what. I don't understand why I can push to other projects (the pull/ push is working fine) but not this one. What do I need to do in order to git push to the repo?

Push gitlab repository code to Google source repository

I followed below article to push gitlab repository code to Google cloud source repository but I'm getting an error on this command
git push -f google master
error: src refspec master does not match any.
error: failed to push some refs to 'https://source.developers.google.com/p/project/r/test/'
Article followed:
https://medium.com/#bamnet/cloud-source-repositories-gitlab-2fdcf1a8e50c
Is there anything , I'm doing wrong 😜? Any thoughts as to how I can avoid this error message?
src refspec master does not match any
The issue is the date of the article you are following: Aug. 2018.
GitLab Runner has changed since then, more precisely in May 2019.
The problem is described in this thread from May 2019:
Since we are using refspec to clone/fetch the repository, we checkout a specific commit and not checking out a specific branch.
When the script does git push master, the branch is nowhere to be found so git doesn’t know what to push.
That was because of, on GitLab side, MR 1203:
Basically, GitLab CE/EE sends refspecs parameter to GitLab Runner gitlab-org/gitlab-foss app/presenters/ci/build_runner_presenter.rb: this parameter is to used in GitLab Runners for fetching branch/tag refs from remote repository.
This change was introduced because we wanted GitLab Rails side to leverage respecs in order for issue 7380 "Combined ref pipelines (source+target branch)" though, there should not be a big difference between git clone $URL or mkdir $REPO_DIR && git remote add origin $URL && git fetch +refs/heads/branch_name:refs/remotes/origin/branch_name.
In fact, the new behavior has already run on our development project
https://gitlab.com/gitlab-org/gitlab-ce/pipelines and has no issues so far.
Issue 4097 was opened at the time
Workaround
Use HEAD when you want to push this to another remote.
deploy:
stage: deploy
script:
- git remote add heroku https://heroku:$HEROKU_API_KEY#git.heroku.com/<project>.git
- git push -f heroku HEAD:master
So don't push master. Push HEAD.
The OP Adam uses another workaround and add:
before_script:
- git checkout master

How to deploy Git LFS on Heroku?

I have completed a project on Node.js which has already pushed into GitHub, this project has a video which larger than 100MB which required Git LFS. Git LFS successfully pushed into the GitHub no issue at all.
The second phase of this project is to host in Heroku, this is where I got stuck. I tried both:
heroku buildpacks:add https://github.com/BureauxLocaux/heroku-buildpack-git-lfs.git
and
heroku buildpacks:add (name of the app given by heroku)/heroku-buildpack-git-lfs
When it's pushed using
git push heroku master --no-verify
I get the following error:
remote: -----> Git LFS app detected
remote: Env var BL_BUILDPACK_GIT_LFS_REPO is not set
remote: ! Push rejected, failed to compile Git LFS app.
remote:
remote: ! Push failed
remote: Verifying deploy...
remote:
remote: ! Push rejected to intense-journey-80070.
remote:
To https://git.heroku.com/intense-journey-89070.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/intense-journey-89070.git'
How can I make this work?
You say
heroku buildpacks:add (name of the app given by heroku)/heroku-buildpack-git-lfs
but you shouldn't use your app name here. I guess you want to use this buildpack? In that case, you should literally do
heroku buildpacks:add https://github.com/BureauxLocaux/heroku-buildpack-git-lfs.git
You also have an error message saying
Env var BL_BUILDPACK_GIT_LFS_REPO is not set
There is some additional configuration required for the buildpack, as outlined in its buildpack page on Heroku, which you appear not to have done:
Set the following environment variable for your app:
BL_BUILDPACK_GIT_LFS_REPO to the clone URL of the repository from which to download Git LFS assets. This should include any username, password, or personal access token which is necessary to clone noninteractively. See here for details on the syntax. It must be something like git#github.com:BureauxLocaux/my-repo
BL_BUILDPACK_GIT_LFS_SSH_PRIVATE_KEY: your private key encoded in base64 with base64 -w 0. You can use heroku config:set --app preprod-bureauxlocaux "BL_BUILDPACK_GIT_LFS_SSH_PRIVATE_KEY=$(cat ~/.ssh/heroku_deploy_lfs | base64 -w 0)" to set it.
Private SSH keys should be protected bordering on paranoia, so make sure to use a dedicated SSH key that is only used for deployment of this repository. Give that deploy key the lowest level of permission that you can.
The files that are linked to Large File System (LFS) are not supported in Heroku.
So you need to move to settings on heroku to add configs vars as key “HEROKU_BUILDPACK_GIT_LFS_REPO” to value “https://#github.com//repository.git” token is a unique personal Access token.
You need to register for that in your GitHub > settings> Developer Settings for Heroku to access your LFS files and also link in buildpacks to install LFS “https://github.com/raxod502/heroku-buildpack-git-lfs.git”.
Lastly, hit the deploy button in the deploy section and you are done with your project and available for people accessing over the internet.
Unfortunately Heroku doesn’t support git LFS at the moment.
Heroku doesn’t support git lfs. Using this method can cause pushes to fail.
https://devcenter.heroku.com/articles/git#deploy-from-a-branch-besides-main
Basically you can simply follow the instruction in this post. What I need to say is that when you register GitHub app, the URL you need to fill in "Webhook URL" and "Homepage URL" is both the URL you created using heroku (Example format: https://<app-name>.herokuapp.com).

How to fix the Heroku failed to push some refs error?

I keep getting the failed to push error when trying to push my project to heroku. I followed a couple other answered questions saying to create a new file and push it before connecting to the master, but it still doesn't work for me.
What else can I do to fix this?
image of the error following me creating a text file
The problem here is that you're trying to push the branch master, but that branch doesn't exist. The branch you're on is masterbranch, as seen by the output of your root commit.
If you want to push this branch to the remote, you can use git push origin masterbranch. If you want to push it to the remote master branch, then you can use git remote push masterbranch:master. If you want to rename it, you can use git branch -m master and then push it.
If you pushed your project source code into GitHub, after you deployed to Heroku, branch will be changed from master to main, so to fix it, type following commands:
git add .
git commit -am "changes made"
git push heroku main
Instead of git push heroku master, if branch was changed from master to main.

Resources