how to deploy custom github branch on vercel
Asked Answered
H

8

26

Is there a way to select a custom branch to deploy ? I do not seem to be able to select a branch and it takes the default main branch

thanks in advance

Hilton answered 10/3, 2021 at 21:11 Comment(0)
L
28

Vercel automatically deploys any commit you push to a branch.

You can also customize which branch is used as the Production Branch in the project settings: Go to Project Settings > Git > Production Branch

Liston answered 18/3, 2021 at 21:44 Comment(2)
Seems no any way to trigger this action by manual function. Only support push the branch to github repos can working. Can't understand this design.Kendricks
You can now manually trigger deployments using "deploy hooks", found in Settings > Git > Deploy Hooks. Create one that points to your branch & navigate to it.Bucher
O
4

This works for me: add the code to vercel.json file in root directory:

{
    "env": {
        "BRANCH": "custom-branch"
    },
    "scripts": {
        "vercel-deploy": "if [ \"$BRANCH\" != \"main\" ]; then echo \"Cannot deploy from $BRANCH branch\"; exit 1; fi"
    }
}
Ostrander answered 18/1, 2023 at 3:16 Comment(0)
L
4

Seems no way to choose a branch when creating a new project. But, after deployment first, you can change Production Branch in Settings/Git configuration.

Loraleeloralie answered 2/9, 2023 at 10:37 Comment(2)
True, but after changing the branch in Settings/Git, you still have to do git push to the branch; there is no other way to trigger its build.Arielariela
After initially deploying from main/master, navigate to the Vercel UI and update the name of the production branch in settings/git, then navigate to deployments and select create new deployment, now select the branch you which to build for the deployment.Pash
B
3

If you want to deploy a branch without pushing a commit, you can use vercel-cli. To re-deploy the preview environment:

vercel --force

To re-deploy the production environment:

vercel --prod --force

If you haven't setup vercel-cli yet check Vercel's CLI document

Source: Deploy An App Without Pushing An Empty Commit

Boarish answered 17/4, 2022 at 21:12 Comment(0)
L
3

I am able to view the latest commit made on my repo by heading to Deployments tab then click the three dots of a specific commit that you want to deploy. Choose the Redeploy option from the drop down list.

screenshot of three dot menu with Redeploy option highlighted

Lenoralenore answered 12/1, 2023 at 7:47 Comment(1)
This works, but only if that commit has already been deployed.Grimaldi
K
0

if you wants' to deploy your code in another branch so please make sure first update your another branch as a main branch on github then you can deploy you main branch in vercel. but theirs is no any other way to deploy your another branch on vercel. Thank you!

Kreg answered 17/5 at 5:52 Comment(0)
L
0

you need to change on github repo by changing the default repo to where every you want it go to github setting in general then go to defaultenter image description here branch you can get the default branch then change it there

Lunde answered 25/6 at 8:59 Comment(0)
W
0

go to the Deployments tab choose your latest commit on the branch and click on the 3 dots initially current tag is on main branch

image1

once you click on 3 dots: promote it to [branch name]

image2

there are a few things which you need to manually tweak.

Wobble answered 21/7 at 9:49 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.