These commands help you manage the git remote URLs for apps in your bench, allowing you to switch between different repositories or reset to official sources.
remote-set-url
Set the remote URL for an app’s git repository.
bench remote-set-url GIT_URL
Arguments
The new git remote URL to set for the app
Examples
Switch to a Fork
# Navigate to app directory first
cd ~/frappe-bench/apps/frappe
# Set remote to your fork
bench remote-set-url https://github.com/yourusername/frappe.git
Use SSH Instead of HTTPS
cd ~/frappe-bench/apps/erpnext
bench remote-set-url [email protected] :yourusername/erpnext.git
Switch to Custom Repository
cd ~/frappe-bench/apps/custom_app
bench remote-set-url https://gitlab.com/yourcompany/custom_app.git
Workflow
Navigate to the app directory
Set the new remote URL
Verify the change with git remote -v
Pull updates from the new remote
cd ~/frappe-bench/apps/frappe
bench remote-set-url https://github.com/yourusername/frappe.git
git remote -v
git pull origin develop
Implementation Details
Location: bench/commands/git.py:15
The command uses bench.utils.set_git_remote_url() to update the git configuration.
remote-reset-url
Reset an app’s remote URL back to the official Frappe repository on GitHub.
bench remote-reset-url APP
Arguments
The name of the app to reset (e.g., frappe, erpnext)
Examples
Reset Frappe to Official Repository
bench remote-reset-url frappe
This sets the remote URL to: https://github.com/frappe/frappe.git
Reset ERPNext
bench remote-reset-url erpnext
This sets the remote URL to: https://github.com/frappe/erpnext.git
Reset HRMS
bench remote-reset-url hrms
This sets the remote URL to: https://github.com/frappe/hrms.git
When to Use
After working with a fork, switch back to official repo
When your custom remote is no longer needed
To receive updates from the official Frappe repository
Before running bench update from official sources
Implementation Details
Location: bench/commands/git.py:21
The command constructs the URL as https://github.com/frappe/{app}.git and calls set_git_remote_url().
This command assumes the app exists in the official Frappe GitHub organization. It won’t work for custom apps that don’t have an official Frappe repository.
remote-urls
Display the remote URLs for all apps in the bench.
Output
The command displays each app and its remote URL:
frappe https://github.com/frappe/frappe.git
erpnext https://github.com/frappe/erpnext.git
hrms [email protected] :yourusername/hrms.git
custom_app https://gitlab.com/yourcompany/custom_app.git
Examples
Check All Remote URLs
cd ~/frappe-bench
bench remote-urls
Check Before Update
# Verify remotes before updating
bench remote-urls
# Update from current remotes
bench update --pull
Audit Repository Sources
# Save remote URLs to file
bench remote-urls > ~/bench-remotes.txt
# Compare with another bench
diff ~/bench-remotes.txt ~/other-bench-remotes.txt
Implementation Details
Location: bench/commands/git.py:28
The command:
Iterates through all apps in the bench
Checks if each app is a git repository
Retrieves the remote name (usually ‘origin’)
Gets the remote URL using git config --get remote.{remote}.url
Displays the app name and URL
Complete Workflow Examples
Fork and Contribute Workflow
# 1. Check current remotes
bench remote-urls
# 2. Switch to your fork
cd ~/frappe-bench/apps/frappe
bench remote-set-url [email protected] :yourusername/frappe.git
# 3. Add upstream remote
git remote add upstream https://github.com/frappe/frappe.git
# 4. Create feature branch
git checkout -b my-feature
# 5. Make changes and push to fork
git add .
git commit -m "Add new feature"
git push origin my-feature
# 6. After PR is merged, reset to official
bench remote-reset-url frappe
git checkout develop
git pull
Working with Multiple Remotes
# Set up both official and fork
cd ~/frappe-bench/apps/frappe
# Set origin to your fork
bench remote-set-url [email protected] :yourusername/frappe.git
# Add upstream for official repo
git remote add upstream https://github.com/frappe/frappe.git
# Fetch from both
git fetch --all
# Check all remotes
git remote -v
Output:
origin [email protected] :yourusername/frappe.git (fetch)
origin [email protected] :yourusername/frappe.git (push)
upstream https://github.com/frappe/frappe.git (fetch)
upstream https://github.com/frappe/frappe.git (push)
Migrate from HTTPS to SSH
# Check current URLs (HTTPS)
bench remote-urls
# Convert each app to SSH
cd ~/frappe-bench/apps/frappe
bench remote-set-url [email protected] :frappe/frappe.git
cd ~/frappe-bench/apps/erpnext
bench remote-set-url [email protected] :frappe/erpnext.git
# Verify change
bench remote-urls
Comparison with Git Commands
Bench Commands bench remote-set-url URL
bench remote-reset-url APP
bench remote-urls
Simplified interface
Works from any directory
Bench-aware
Git Commands git remote set-url origin URL
git remote -v
More control
Standard git workflow
Multiple remotes
Troubleshooting
If you get authentication errors: # Use SSH instead of HTTPS
bench remote-set-url [email protected] :username/repo.git
# Or configure git credentials
git config --global credential.helper store
If the URL is incorrect: # Check current remotes
cd apps/app_name
git remote -v
# Set correct URL
bench remote-set-url https://github.com/correct/url.git
# Verify
git remote -v
Reset Not Working for Custom App
remote-reset-url only works for official Frappe apps:# For custom apps, use remote-set-url instead
bench remote-set-url https://github.com/yourorg/custom_app.git
# Or use git directly
cd apps/custom_app
git remote set-url origin https://github.com/yourorg/custom_app.git
bench update - Pull updates from remote repositories
switch-to-branch - Switch branches across apps
git remote - Git’s built-in remote management