Version control for ArcGIS web maps — Git-like branching, commits, diff, and Portal sync
Project description
GitMap
Version control for ArcGIS web maps
GitMap provides Git-like version control for ArcGIS Online and Enterprise Portal web maps. Branch, commit, diff, merge, push, and pull maps using familiar workflows.
Table of Contents
- Features
- Installation
- Quick Start
- Configuration
- CLI Commands
- Usage Examples
- Docker Setup
- Development
- Architecture
Features
- Version Control: Track changes to ArcGIS web maps with commits and branches
- Branching: Create feature branches for parallel development
- Diffing: Compare map versions and see layer-level changes
- Merging: Merge branches with conflict resolution
- Portal Integration: Push and pull maps to/from ArcGIS Portal or ArcGIS Online
- Map Discovery: List and search available web maps from Portal with the
listcommand - Layer Settings Transfer: Transfer popup and form settings between maps with the
lsmcommand - Bulk Repository Setup: Automate cloning multiple maps with owner filtering
- Auto-Pull: Automatically sync all repositories with Portal to keep them up to date (with optional auto-commit)
- Context Visualization: Visualize event history and relationships in multiple formats (Mermaid, ASCII, HTML)
- CLI Interface: Familiar Git-like command-line interface
- Rich Output: Beautiful terminal output with colors and formatting
Installation
Prerequisites
- Python 3.11, 3.12, or 3.13 (arcgis SDK requires Python <3.14)
- ArcGIS Portal or ArcGIS Online account
- pip (Python package manager)
Install from Source
- Clone the repository:
git clone <repository-url>
cd gitmap
- Install the core library:
pip install -e packages/gitmap_core
- Install the CLI:
pip install -e apps/cli/gitmap
Verify Installation
gitmap --version
You should see: gitmap, version 0.5.0
Quick Start
1. Configure Authentication
Create a .env file in the project root (or copy from configs/env.example):
cp configs/env.example .env
Edit .env with your credentials:
PORTAL_URL=https://your-org.maps.arcgis.com
PORTAL_USER=your_username
PORTAL_PASSWORD=your_password
Note: The .env file is git-ignored and should never be committed.
2. Initialize a Repository
Start a new GitMap repository:
gitmap init
Or initialize with project details:
gitmap init --project-name "My Web Map" --user-name "John Doe" --user-email "john@example.com"
3. Clone an Existing Map
Clone a web map from Portal:
gitmap clone <item_id>
Example:
gitmap clone abc123def456 --directory my-project
4. Make Changes and Commit
After modifying your map JSON:
# Check status
gitmap status
# Commit changes
gitmap commit -m "Added new operational layer"
5. Push to Portal
Push your changes to Portal:
gitmap push
Configuration
Repository Configuration
GitMap stores configuration in .gitmap/config.json:
{
"version": "1.0",
"user_name": "John Doe",
"user_email": "john@example.com",
"project_name": "MyProject",
"remote": {
"name": "origin",
"url": "https://www.arcgis.com",
"folder_id": "abc123",
"item_id": "def456"
}
}
Environment Variables
GitMap supports the following environment variables (set in .env or your shell):
PORTAL_URL- Portal URL (defaults tohttps://www.arcgis.comfor ArcGIS Online)PORTAL_USER- Portal usernamePORTAL_PASSWORD- Portal passwordARCGIS_USERNAME- Alternative username variableARCGIS_PASSWORD- Alternative password variable
Authentication Methods
GitMap attempts authentication in this order:
- Username/password provided via command-line options
- Environment variables from
.envfile - ArcGIS Pro authentication (if running in ArcGIS Pro)
- Anonymous access (limited functionality)
CLI Commands
gitmap init
Initialize a new GitMap repository.
gitmap init [PATH] [OPTIONS]
Options:
--project-name, -n- Project name (defaults to directory name)--user-name, -u- Default author name for commits--user-email, -e- Default author email for commits
Examples:
gitmap init
gitmap init --project-name "My Project"
gitmap init /path/to/project --user-name "John Doe"
gitmap clone
Clone a web map from Portal.
gitmap clone <ITEM_ID> [OPTIONS]
Options:
--directory, -d- Directory to clone into (defaults to map title)--url, -u- Portal URL (defaults to ArcGIS Online)--username- Portal username (or use env var)
Examples:
gitmap clone abc123def456
gitmap clone abc123def456 --directory my-project
gitmap clone abc123def456 --url https://portal.example.com
gitmap setup-repos
Bulk clone web maps into a repositories directory.
gitmap setup-repos [OPTIONS]
Description:
Automates the setup of a repositories directory by cloning multiple web maps at once. Each map is cloned into its own subdirectory with a .gitmap folder. Useful for setting up local copies of multiple maps owned by a specific user or matching specific criteria.
Options:
--directory, -d- Directory to clone repositories into (defaults to 'repositories')--owner, -o- Filter web maps by owner username--query, -q- Search query to filter web maps (e.g., 'title:MyMap')--tag, -t- Filter web maps by tag--max-results, -m- Maximum number of web maps to clone (default: 100)--url, -u- Portal URL (or use PORTAL_URL env var)--username- Portal username (or use env var)--password- Portal password (or use env var)--skip-existing- Skip maps that already have directories (instead of failing)
Examples:
# Clone all maps owned by a specific user
gitmap setup-repos --owner myusername
# Clone to a custom directory
gitmap setup-repos --owner myusername --directory my-repos
# Clone maps with a specific tag
gitmap setup-repos --tag production --skip-existing
# Clone maps matching a search query
gitmap setup-repos --query "title:Project*" --owner myusername
# Combine filters
gitmap setup-repos --owner myusername --tag production --max-results 50
gitmap auto-pull
Automatically pull updates for all GitMap repositories in a directory.
gitmap auto-pull [OPTIONS]
Description: Scans a directory for GitMap repositories and pulls the latest changes from Portal for each one. Useful for keeping multiple local repositories in sync with their Portal counterparts. Can be run manually or scheduled via cron/systemd timer for automated synchronization.
Options:
--directory, -d- Directory containing GitMap repositories (defaults to 'repositories')--branch, -b- Branch to pull for each repository (defaults to 'main')--url, -u- Portal URL (or use PORTAL_URL env var)--username- Portal username (or use env var)--password- Portal password (or use env var)--skip-errors- Continue pulling other repos if one fails (default: True)--auto-commit- Automatically commit changes after successful pull (default: False)--commit-message, -m- Custom commit message template (use {repo} for repository name, {date} for timestamp)
Examples:
# Pull updates for all repositories in the default 'repositories' directory
gitmap auto-pull
# Pull from a custom directory
gitmap auto-pull --directory my-repos
# Pull a specific branch from all repositories
gitmap auto-pull --branch production
# Pull with custom Portal URL
gitmap auto-pull --url https://portal.example.com
# Automatically commit changes after pulling
gitmap auto-pull --auto-commit
# Use a custom commit message template
gitmap auto-pull --auto-commit --commit-message "Auto-pull from Portal on {date}"
# Schedule with cron (every hour)
0 * * * * cd /path/to/project && gitmap auto-pull --auto-commit
gitmap list
List all available web maps from Portal or ArcGIS Online.
gitmap list [OPTIONS]
Description: Queries Portal/ArcGIS Online and displays all available web maps in a table format. Useful for discovering web map item IDs before cloning or browsing available maps in your organization.
Options:
--query, -q- Search query to filter web maps (e.g., 'title:MyMap')--owner, -o- Filter web maps by owner username--tag, -t- Filter web maps by tag--max-results, -m- Maximum number of web maps to return (default: 100)--url, -u- Portal URL (or use PORTAL_URL env var)--username- Portal username (or use env var)--password- Portal password (or use env var)
Examples:
# List all web maps
gitmap list
# List web maps owned by a specific user
gitmap list --owner myusername
# List web maps with a specific tag
gitmap list --tag production
# Combine filters
gitmap list --owner myusername --tag production
# Search by title
gitmap list --query "title:MyMap"
# Limit results
gitmap list --max-results 50
gitmap status
Show the working tree status.
gitmap status
Displays:
- Current branch
- Staged changes
- Unstaged changes
- Untracked files
gitmap branch
List, create, or delete branches.
gitmap branch [BRANCH_NAME] [OPTIONS]
Options:
--delete, -d- Delete a branch--list, -l- List all branches
Examples:
gitmap branch # List branches
gitmap branch feature/new-layer # Create new branch
gitmap branch -d feature/old # Delete branch
gitmap checkout
Switch branches or restore working tree files.
gitmap checkout <BRANCH_NAME>
Examples:
gitmap checkout feature/new-layer
gitmap checkout main
gitmap commit
Record changes to the repository.
gitmap commit [OPTIONS]
Options:
--message, -m- Commit message (required)--author- Override commit author
Examples:
gitmap commit -m "Added new layer"
gitmap commit -m "Fixed layer visibility" --author "Jane Doe"
gitmap diff
Show changes between commits, branches, or working tree.
gitmap diff [OPTIONS]
Options:
--branch, -b- Compare with branch--commit, -c- Compare with commit
Examples:
gitmap diff # Show working tree changes
gitmap diff --branch main # Compare with main branch
gitmap diff --commit abc123 # Compare with specific commit
gitmap log
Show commit history.
gitmap log [OPTIONS]
Options:
--branch, -b- Show log for specific branch--limit, -n- Limit number of commits
Examples:
gitmap log
gitmap log --branch feature/new-layer
gitmap log --limit 10
gitmap merge
Merge branches.
gitmap merge <BRANCH_NAME>
Examples:
gitmap merge feature/new-layer
gitmap push
Push changes to Portal.
gitmap push [OPTIONS]
Options:
--branch, -b- Branch to push (defaults to current)--url, -u- Portal URL--username- Portal username
Examples:
gitmap push
gitmap push --branch feature/new-layer
gitmap push --url https://portal.example.com
gitmap pull
Pull changes from Portal.
gitmap pull [OPTIONS]
Options:
--branch, -b- Branch to pull (defaults to current)--url, -u- Portal URL--username- Portal username
Examples:
gitmap pull
gitmap pull --branch main
gitmap lsm
Transfer popup and form settings between maps.
gitmap lsm <SOURCE> [TARGET] [OPTIONS]
Description:
Transfers popupInfo and formInfo from layers and tables in a source map to matching layers and tables in a target map. Works with item IDs, branch names, commit IDs, or file paths. Automatically handles nested layers within GroupLayers.
Options:
--dry-run- Preview changes without applying them
Arguments:
SOURCE- Source map (item ID, branch name, commit ID, or file path)TARGET- Target map (optional, defaults to current index)
Examples:
# Transfer settings between branches
gitmap lsm main feature/new-layer
# Transfer from Portal item ID to current index
gitmap lsm abc123def456
# Transfer from file to file with dry-run
gitmap lsm source.json target.json --dry-run
# Transfer from another repository directory
gitmap lsm ../other-repo
gitmap notify
Send a notification to members of a Portal/AGOL group using the
ArcGIS API for Python Group.notify method (leveraging your Portal/AGOL
authentication; no SMTP settings required). Notifications go to users in
the target group according to their ArcGIS notification preferences.
By default, all group members are notified. Use --user to target specific
users (useful for testing).
gitmap notify --group <GROUP_ID_OR_TITLE> --subject "Subject" --message "Body"
Options:
--group, -g- Group ID or title to target for notifications (required)--user- Specific username(s) to notify (can be used multiple times). If omitted, all group members are notified.--subject, -s- Notification subject line--message, -m- Notification body (or use--message-file)--message-file- Load the notification body from a text file--url, -u- Portal URL (defaults to ArcGIS Online)--username/--password- Portal credentials (or use env vars)
Examples:
# Notify all members of the editors group
gitmap notify --group editors --subject "Release planned" \
--message "New basemap will be published on Friday."
# Test by sending to a single user
gitmap notify --group editors --user testuser --subject "Test notification" \
--message "This is a test message."
# Notify multiple specific users
gitmap notify --group editors --user user1 --user user2 --subject "Update" \
--message "Please review the changes."
# Load a longer message from a file
gitmap notify --group "Field Crew" --subject "Inspection prep" --message-file notes.txt
gitmap context
Visualize and manage the context graph showing events, relationships, and annotations.
gitmap context <SUBCOMMAND> [OPTIONS]
Description: The context command provides tools for visualizing the event history and relationships in your GitMap repository. It tracks all operations (commits, pushes, pulls, merges, branches, diffs) and displays them in various formats suitable for terminal viewing or export to IDEs.
Subcommands:
show- Display context graph in terminal (ASCII, Mermaid, or Mermaid Timeline formats)export- Export context graph to file (Mermaid, ASCII, or HTML)timeline- Show ASCII timeline of context eventsgraph- Show ASCII graph of event relationships
Options (for show and timeline):
--format, -f- Output format:ascii,mermaid, ormermaid-timeline(default: ascii)--limit, -n- Maximum events to display (default: 20)--type, -t- Filter by event types (can be used multiple times):commit,push,pull,merge,branch,diff--no-unicode- Use simple ASCII characters (no Unicode)
Options (for export):
--format, -f- Output format:mermaid,mermaid-timeline,mermaid-git,ascii,ascii-graph, orhtml(default: mermaid)--output, -o- Output file path (defaults to context.)--limit, -n- Maximum events to include (default: 50)--type, -t- Filter by event types--title- Title for the visualization--theme- Color theme for HTML output:lightordark(default: light)--direction- Graph direction for Mermaid flowcharts:TB,BT,LR, orRL(default: TB)--no-annotations- Exclude annotations from visualization
Examples:
# Display context graph in terminal
gitmap context show
# Display as Mermaid diagram
gitmap context show --format mermaid
# Show only commits and pushes
gitmap context show --type commit --type push
# Export to Mermaid file for IDE viewing
gitmap context export
# Export to HTML with dark theme
gitmap context export --format html --theme dark -o context.html
# Export with custom title and direction
gitmap context export --format mermaid --direction LR --title "My Project Timeline"
# Show timeline of recent events
gitmap context timeline
# Show event relationship graph
gitmap context graph -n 15
gitmap config
Manage repository configuration settings.
gitmap config [OPTIONS]
Description: Configure repository settings such as the production branch (which triggers notifications on push) and auto-visualization (automatically regenerates context graph after events).
Options:
--production-branch, -p- Set the production branch name (branch that triggers notifications on push)--unset-production- Remove the production branch setting--auto-visualize- Enable automatic context graph regeneration after events--no-auto-visualize- Disable automatic context graph regeneration
Examples:
# View current configuration
gitmap config
# Set production branch
gitmap config --production-branch main
# Set production branch to a release branch
gitmap config --production-branch release/1.0.0
# Remove production branch setting
gitmap config --unset-production
# Enable auto-visualization
gitmap config --auto-visualize
# Disable auto-visualization
gitmap config --no-auto-visualize
Usage Examples
Workflow: Bulk Repository Setup
# Set up a repositories directory with all maps owned by a user
gitmap setup-repos --owner myusername --directory my-maps
# Navigate into one of the cloned repositories
cd my-maps/MyWebMap
# Check the status
gitmap status
# Make changes and commit
gitmap commit -m "Updated layer symbology"
# Push back to Portal
gitmap push
Workflow: Keeping Repositories in Sync
# Pull updates for all repositories at once
gitmap auto-pull
# Pull from a specific directory
gitmap auto-pull --directory my-maps
# Set up automated synchronization with cron (runs every hour)
# Add this to your crontab (crontab -e):
0 * * * * cd /path/to/project && /path/to/gitmap auto-pull --directory repositories
# Or use systemd timer for more control
# Create /etc/systemd/system/gitmap-sync.service and gitmap-sync.timer
Workflow: Creating a New Feature
# 1. Start from main branch
gitmap checkout main
# 2. Create feature branch
gitmap branch feature/add-basemap
# 3. Switch to feature branch
gitmap checkout feature/add-basemap
# 4. Make changes to your map (edit JSON files)
# 5. Check what changed
gitmap status
gitmap diff
# 6. Commit changes
gitmap commit -m "Added new basemap layer"
# 7. Push to Portal
gitmap push --branch feature/add-basemap
# 8. Merge back to main
gitmap checkout main
gitmap merge feature/add-basemap
gitmap push
Workflow: Collaborating with Others
# 1. Pull latest changes from Portal
gitmap pull
# 2. Check for conflicts
gitmap status
# 3. If conflicts exist, resolve them manually
# Then commit the resolution
gitmap commit -m "Resolved merge conflicts"
# 4. Push resolved changes
gitmap push
Workflow: Comparing Versions
# Compare current working tree with main branch
gitmap diff --branch main
# Compare two specific commits
gitmap diff --commit abc123 --commit def456
# View commit history
gitmap log --limit 20
Workflow: Transferring Layer Settings
# Transfer popup and form settings from one branch to another
gitmap checkout feature/new-layer
gitmap lsm main
# Preview what would be transferred (dry-run)
gitmap lsm main feature/new-layer --dry-run
# Transfer settings from a Portal item ID
gitmap lsm abc123def456
# Transfer settings between different repositories
gitmap lsm ../source-repo
Docker Setup
GitMap includes Docker support for consistent development environments.
Development Shell
Start an interactive development shell:
docker-compose up dev
This provides:
- Python 3.11 environment
- All dependencies installed
- Volume mounts for live code editing
- ArcGIS cache persistence
Running Apps
Run a specific app:
APP_GROUP=cli APP_NAME=gitmap docker-compose up app
Development
Project Structure
gitmap/
├── apps/ # Runnable applications
│ └── cli/
│ └── gitmap/ # CLI application
├── packages/ # First-party libraries
│ └── gitmap_core/ # Core library
├── configs/ # Configuration templates
├── docker/ # Docker configuration
└── documentation/ # Specifications and docs
Installing for Development
# Install core library in editable mode
pip install -e packages/gitmap_core
# Install CLI in editable mode
pip install -e apps/cli/gitmap
Running Tests
# From project root
pytest
Code Standards
- Python 3.11+
- PEP 8 style guide
- Type hints required
- PEP 257 docstrings
- Uses
pathlib.Pathfor file operations
Architecture
Core Components
-
gitmap_core: Core library providing:- Repository management (
.gitmapdirectory structure) - Portal authentication and connection
- Web map JSON operations
- Diff and merge algorithms
- Remote push/pull operations
- Repository management (
-
gitmap-cli: Command-line interface providing:- 18 Git-like commands (including
list,lsm,setup-repos,auto-pull,notify,context, andconfig) - Rich terminal output
- User-friendly error messages
- 18 Git-like commands (including
Repository Structure
GitMap stores version control data in a .gitmap directory:
.gitmap/
├── config.json # Repository configuration
├── HEAD # Current branch reference
├── index.json # Staging area
├── refs/
│ └── heads/ # Branch references
└── objects/
└── commits/ # Commit objects
Data Model
- Commit: Snapshot of map state with metadata
- Branch: Named pointer to a commit
- Remote: Portal connection configuration
- Config: Repository settings and defaults
Troubleshooting
Authentication Issues
If you encounter authentication errors:
- Verify your
.envfile exists and contains correct credentials - Check that environment variables are set:
echo $PORTAL_USER echo $PORTAL_PASSWORD
- Try providing credentials via command-line options
- Verify Portal URL is correct
Common Errors
"Not connected. Call connect() first"
- Ensure you've authenticated with Portal
- Check your
.envfile configuration
"Repository already exists"
- Remove existing
.gitmapdirectory if starting fresh - Or work within the existing repository
"Failed to connect to Portal"
- Verify Portal URL is accessible
- Check network connectivity
- Confirm credentials are correct
Contributing
Contributions are welcome! Please:
- Follow the code standards outlined in
documentation/project_specs/ - Add tests for new features
- Update documentation as needed
- Submit pull requests with clear descriptions
License
MIT License - see LICENSE file for details
Support
For issues, questions, or contributions:
- Open an issue on the repository
- Review documentation in
documentation/ - Check specifications in
documentation/project_specs/
GitMap - Version control for ArcGIS web maps
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file gitmap_core-0.1.0.tar.gz.
File metadata
- Download URL: gitmap_core-0.1.0.tar.gz
- Upload date:
- Size: 242.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1ac300c6a6e7896e7c56d0479356d20a14ba65c9368268723b86da5fb4a23423
|
|
| MD5 |
26f8084630cf7e83482bf86cf963e09f
|
|
| BLAKE2b-256 |
792d3ac20dd26d91f6b6d1dcc1112e68ccc43a7231430eda965c584833e87058
|
File details
Details for the file gitmap_core-0.1.0-py3-none-any.whl.
File metadata
- Download URL: gitmap_core-0.1.0-py3-none-any.whl
- Upload date:
- Size: 112.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a5255af5a1dd9eaf5339bfc8a9875dfeacec424d7132ac0f4cd308a024b0c3d1
|
|
| MD5 |
9146bb49fc2554e383b6ecff7e8962eb
|
|
| BLAKE2b-256 |
7970faa50717b02ef414c45419481e8c6a5e88f7eee0c69b66f2113f27fdf3ce
|