Issue
I want to change the default branch for my Appsmith apps.
Resolution
Let's address the two scenarios where users might want to change their default branch:
Scenario 1 ✅
Multiple apps are connected to a single repository, and the user wants to have different default branches for different apps. This is supported in Appsmith Enterprise Edition, you can follow the below steps to achieve this -
- Open the desired git connected app in Appsmith.
- Click on the ⚙️ option in the bottom bar beside Git action buttons.
- Find the "Default Branch" section and click on the dropdown menu.
- Select the preferred branch that you want to set as the default.
- After selecting the new default branch, click on "Update" button to apply the changes.
- The default branch for your app in Appsmith will now be updated to the branch you selected.
![Default branch option in Git settings - Appsmith](/sites/default/files/styles/wide/public/2023-12/Capture-2023-12-01-202917.png?itok=RVz8y7rc)
Scenario 2 ✅
A single app is connected to a repository, and the user wants to change the default branch for that app. The following are the steps to achieve this -
Step 1 -
Go to git-sync, and check if the new default branch exists in the remote repository: `origin/temp`
![Current Default Branch](/sites/default/files/styles/wide/public/2023-06/Screenshot%202023-06-27%20at%206.39.37%20PM.png?itok=8h8l5g49)
Step 2 -
Go to the remote repository and go to the `settings > general settings` section
![Default Branch in Repo](/sites/default/files/styles/wide/public/2023-06/Screenshot%202023-06-27%20at%206.34.31%20PM.png?itok=TTe7HPX_)
![Settings Tab](/sites/default/files/styles/wide/public/2023-06/Screenshot%202023-06-27%20at%206.34.48%20PM.png?itok=XriN-DDc)
![General Settings](/sites/default/files/styles/wide/public/2023-06/Screenshot%202023-06-27%20at%206.34.58%20PM.png?itok=6eytiKNe)
Step 3 -
Find the Default Branch section and click on the `switch to different branch` button to select and update the new default branch. Lastly, click on `I understand ...` for it to take an affect.
![Default branch section](/sites/default/files/styles/wide/public/2023-06/Screenshot%202023-06-27%20at%206.35.12%20PM.png?itok=wdU7uyCM)
![Switch default branch](/sites/default/files/styles/wide/public/2023-06/Screenshot%202023-06-27%20at%206.35.29%20PM.png?itok=ht8akKAH)
![I understand](/sites/default/files/styles/wide/public/2023-06/Screenshot%202023-06-27%20at%206.35.57%20PM.png?itok=t_bC9BtX)
Step 4 -
Go back to your Appsmith app and click on `sync branches` to synch the default branch change from the repository.
![Sync branches](/sites/default/files/styles/wide/public/2023-06/Screenshot%202023-06-27%20at%206.33.10%20PM.png?itok=M2o-Nw5S)
Tada 🎉
Now when you enter the edit mode, by default the `temp` branch will be selected.
![Default Branch Test](/sites/default/files/styles/wide/public/2023-06/Screenshot%202023-06-27%20at%206.33.51%20PM.png?itok=VwYUJ5eE)