Skip to content

Switching Branch and Tag of ERPNext from Develop to 14.x.x

By Codenet SolutionsUpdated 6 December 20263 min read

While setting up a new Frappe development server, I encountered a common mistake that caused significant issues. The live server was running Frappe v14 and ERPNext v14, but while creating the dev server, I mistakenly installed ERPNext on the develop branch instead of version-14.

Without noticing this mismatch, I restored the database backup from the live server. After a successful restoration, attempting to migrate the database resulted in multiple errors, such as missing modules and missing doctypes.

Uninstalling and reinstalling ERPNext would have deleted all the data, requiring another backup restoration. To avoid wasting time, I followed a structured approach to switch the branch correctly without data loss. Below are the steps I took.


Back up first:

bench --site your-site backup --with-files

Step 1: Verify Your Current Setup

Before making any changes, check which branch you’re on:

cd ~/frappe-bench/apps/erpnext
git branch

If you see develop or another branch, you’ll need to switch to version-14.

Additionally, verify your remote repository:

git remote -v

Make sure you’re fetching from the correct repository (upstream or origin).


Quick Method: bench switch-to-branch

Warning: this command discards uncommitted changes in the apps it switches. Run git status in each app first, and git stash anything you need.

cd ~/frappe-bench
bench switch-to-branch version-14 frappe erpnext
bench update --patch

It expects a remote named upstream. The manual steps below switch the branches by hand.


Step 2: Check Your Remote Name

The commands below use the upstream remote. If git remote -v shows origin instead, use that name.


Step 3: Checkout ERPNext Version 14

Fetch the version-14 branch and switch to it:

cd ~/frappe-bench/apps/erpnext
git fetch upstream version-14
git checkout -b version-14 FETCH_HEAD

To verify the switch:

git branch

You should now see:

  develop
* version-14

Step 4: Switch Frappe to Version 14

Since ERPNext relies on Frappe, you must also switch your Frappe repository to version-14:

cd ~/frappe-bench/apps/frappe
git fetch upstream version-14
git checkout -b version-14 FETCH_HEAD

Confirm the branch:

git branch

Step 5: Apply Migrations and Update Dependencies

Now that both ERPNext and Frappe are on version 14, update the system:

cd ~/frappe-bench
bench update --patch
bench migrate
bench restart

This ensures your database schema is updated and everything works smoothly.


Step 6: Verify the Upgrade

Run the following command to check the installed versions:

bench version

Expected output:

erpnext 14.x.x
frappe  14.x.x

If everything looks good, restart your bench:

bench start

Now, open ERPNext in your browser at:

http://localhost:8000

or your server’s domain.


Troubleshooting

Unstaged Changes Error

If bench update --patch fails due to unstaged changes, reset them:

Warning: this permanently deletes uncommitted changes in the app. Run git status first, and git stash anything you need.

cd ~/frappe-bench/apps/erpnext
git reset --hard
cd ~/frappe-bench/apps/frappe
git reset --hard

Then retry:

bench update --reset

Missing Dependencies

If bench update --patch fails due to missing dependencies, install them:

bench setup requirements
bench update --patch

Final Thoughts

By following these steps, I successfully switched ERPNext from the develop branch to version-14 without losing data. Mistakes like installing ERPNext on the wrong branch can happen, but by following a structured recovery approach, you can avoid unnecessary reinstallation and data loss.

Always verify the branch before restoring backups!

If you encounter any issues, let me know in the comments! 🚀

Stuck on an upgrade or a failed migration? See our ERPNext and Frappe implementation service.

Related: Fix the bench get-app uv error.