Environment Mapping
Branch patterns help you automatically map your Git branches to the correct environment (Dev, Staging, Production, etc.). You can use either exact matching or regex patterns.
Pattern Types
1. Exact Match
Match the branch name exactly as written.
Example:
-
Pattern:
main
-
Matches:
main
-
Doesn't match:
main-backup
,feature/main
When to use: When you have specific branch names like main
, master
, production
.
2. Regex Patterns
Use regular expressions for flexible matching.
Common Pattern Examples
Match branches starting with a prefix
Pattern | Description | Matches | Doesn't Match |
---|---|---|---|
^dev/ | Branches starting with "dev/" | dev/feature-123 dev/bug-fix | development/test my-dev/branch |
^feature/ | Branches starting with "feature/" | feature/login feature/payment | new-feature/test feature |
^hotfix/ | Branches starting with "hotfix/" | hotfix/critical-bug hotfix/security | fix/hotfix/issue |
^release/ | Branches starting with "release/" | release/v1.0 release/2024-01 | pre-release/test |
Key symbol: ^
means "start of the branch name"
Match specific branch names
Pattern | Description | Matches | Doesn't Match |
---|---|---|---|
^main$ | Exactly "main" | main | main-backup main/dev |
^master$ | Exactly "master" | master | master-old new-master |
^(main|master)$ | Either "main" or "master" | main master | main-dev master-backup |
Key symbol: $
means "end of the branch name"
Match branches with version numbers
Pattern | Description | Matches | Doesn't Match |
---|---|---|---|
^release/v\d+ | Releases starting with "v" + number | release/v1 release/v2.0 | release/version1 release/beta |
^release/\d+\.\d+ | Releases with version format | release/1.0 release/2.5 | release/v1.0 release/beta |
Key symbol: \d
means "any digit (0-9)"
Match pull request branches
Pattern | Description | Matches | Doesn't Match |
---|---|---|---|
^pull/\d+ | GitHub pull request branches | pull/123/merge pull/456/head | pr/123 pull-request/123 |
^pr-\d+ | Custom PR branch format | pr-123 pr-456-fix | pull/123 pr/123 |
Case-Insensitive Matching
Use the (?i)
prefix to match branch names regardless of case (uppercase/lowercase).
Pattern | Description | Matches | Doesn't Match |
---|---|---|---|
(?i)^NEW1$ | Exactly "NEW1" (any case) | NEW1 , new1 , New1 , nEw1 | NEW2 , NEW |
(?i)^release/ | Branches starting with "release/" (any case) | release/v1.0 RELEASE/v1.0 Release/v1.0 | releases/v1.0 |
(?i)^(main|master)$ | Either "main" or "master" (any case) | main , MAIN , Main master , MASTER | main-dev master-old |
Key symbol: (?i)
at the start makes the entire pattern case-insensitive
Examples:
Case-sensitive | ^dev/ | matches "dev/feature" only |
---|---|---|
Case-insensitive | (?i)^dev/ | matches "dev/feature", "DEV/feature", "Dev/feature" |
Case-sensitive | ^main$ | matches "main" only |
Case-insensitive | (?i)^main$ | matches "main", "MAIN", "Main", "mAiN" |
When to use: When your team uses inconsistent casing in branch names (e.g., some use release/
, others use Release/
, or RELEASE/
)
Regex Symbols Reference
Symbol | Meaning | Example | Matches |
---|---|---|---|
^ | Start of branch name | ^dev | dev/feature ✅ my-dev ❌ |
$ | End of branch name | main$ | main ✅ main-old ❌ |
(?i) | Case-insensitive flag | (?i)^main$ | main MAIN Main ✅ |
. | Any single character | dev. | dev/ dev- dev1 |
* | Zero or more of the previous | dev.* | dev dev/feature development |
+ | One or more of the previous | dev.+ | dev/feature ✅ dev ❌ |
\d | Any digit (0-9) | v\d | v1 v2 v9 |
| | OR (either/or) | dev|qa | dev qa |
[ ] | Any character in brackets | [0-9] | 0, 1, 2, ..., 9 |
( ) | Group patterns | ^(dev|qa)/ | dev/test qa/test |
[^ ] | Any character NOT in brackets | [^0-9] | a, b, - (not digits) |
Best Practices
DOs
1. Use ^
to anchor at the start
✅ | ^dev/ | (matches only branches starting with "dev/") |
---|---|---|
❌ | dev/ | (matches anywhere - could match "old-dev/test") |
2. Use $
for exact matches
✅ | ^main$ | (matches only "main") |
---|---|---|
❌ | ^main | (matches "main", "main-old", "maintenance") |
3. Escape special characters
✅ | ^release/v\d+.\d+ | (matches "release/v1.0") |
---|---|---|
❌ | ^release/v\d+.\d+ | (. matches any character) |
4. Test your patterns before using - Use the platform's pattern tester or tools like regex101.com (opens in a new tab)
5. Use (?i)
for case-insensitive matching
✅ | (?i)^release/ | (matches "release/", "RELEASE/", "Release/") |
---|---|---|
❌ | ^[Rr][Ee][Ll]... | (complex and hard to maintain) |
DON'Ts
1. Don't use patterns without anchors (unless intentional)
⚠️ | dev* | (matches "d", "de", "dev", "u" in "pull") |
---|---|---|
✅ | ^dev | (matches branches starting with "dev") |
2. Don't use special characters (security risk)
❌ | dev;echo | (contains dangerous character ;) |
---|---|---|
❌ | devcmd | (contains dangerous character `) |
3. Don't make patterns too broad
❌ | .* | (matches everything) |
---|---|---|
❌ | .+ | (matches any branch with at least 1 character) |
Common Use Cases
Use Case 1: Traditional Git Flow
Production: | ^(main|master)$ |
---|---|
Staging: | ^(staging|stage)$ |
Development: | ^(dev|develop)$ |
Features: | ^feature/ |
Hotfixes: | ^hotfix/ |
Releases: | ^release/ |
Use Case 2: Environment-based Prefixes
Production: | ^prod/ |
---|---|
Staging: | ^stg/ |
QA: | ^qa/ |
Development: | ^dev/ |
Use Case 3: Team-based Branches
Team Alpha: | ^alpha/ |
---|---|
Team Beta: | ^beta/ |
Shared: | ^shared/ |
Main: | ^main$ |
Use Case 4: Version-based Releases
Production: | ^release/v\d+.\d+.\d+$ |
---|---|
Release Candidates: | ^release/v\d+.\d+.\d+-rc\d+$ |
Beta: | ^release/v\d+.\d+.\d+-beta$ |
Development: | ^develop$ |
Use Case 5: Case-Insensitive Environments
When your team uses inconsistent casing:
Production | (?i)^(main|master)$ | matches main, MAIN, Main, master, MASTER |
---|---|---|
Staging | (?i)^(staging|stage)$ | matches staging, STAGING, Staging |
QA | (?i)^qa/ | matches qa/, QA/, Qa/ |
Development | (?i)^dev/ | matches dev/, DEV/, Dev/ |
Testing Your Patterns
Example: Testing ^dev/
Branch Name | Match? | Reason |
---|---|---|
dev/feature-login | ✅ Yes | Starts with "dev/" |
dev/bug-fix | ✅ Yes | Starts with "dev/" |
development/test | ❌ No | Starts with "development/", not "dev/" |
my-dev/branch | ❌ No | Doesn't start with "dev/" |
feature/dev/test | ❌ No | Doesn't start with "dev/" |
Example: Testing ^release/v\d+\.\d+
Branch Name | Match? | Reason |
---|---|---|
release/v1.0 | ✅ Yes | Matches pattern |
release/v2.5 | ✅ Yes | Matches pattern |
release/v1.0.3 | ✅ Yes | Matches pattern (and more) |
release/version1.0 | ❌ No | Missing "v" before number |
release/beta | ❌ No | No version number |
Warnings vs Errors
The platform validates your patterns and provides:
Errors (Blocks saving)
-
Invalid characters: ;, &, `, ", ', <, >, %
-
Invalid regex syntax: Unclosed brackets, invalid escape sequences
Example:
❌ | dev;echo hack | (contains dangerous character ;) |
---|---|---|
❌ | dev[test | (unclosed bracket) |
Warnings (Allows saving with notice)
- Unanchored patterns: Patterns that might match unintentionally
Example:
⚠️ | dev* | Warning: Will match "u" in "pull/ud/merge" |
---|
Suggestion: Use "^dev" instead
You can still use warned patterns if the behavior is intentional.
Need Help?
-
Regex Tester: regex101.com (opens in a new tab) (choose "ECMAScript/JavaScript" flavor)
-
Quick Tip: Start simple (exact match or ^prefix/) and add complexity only when needed
-
Questions? Contact support with your branch naming convention, and we'll help create the right patterns
Quick Reference Card
Symbol | Meaning | Example |
---|---|---|
^ | Start of name | ^dev → "dev/test" ✅ |
$ | End of name | main$ → "main" ✅ |
(?i) | Case-insensitive | (?i)^main$ → "main", "MAIN" ✅ |
\d | Any digit | v\d → "v1" ✅ |
\d+ | One or more digits | \d+ → "123" ✅ |
. | Any character | dev. → "dev/" ✅ |
.* | Zero or more chars | dev.* → "dev", "development" ✅ |
| | OR | dev|qa → "dev" or "qa" ✅ |
( ) | Group | ^(dev|qa)/ → "dev/" or "qa/" ✅ |
[abc] | Any of a, b, or c | [0-9] → digits ✅ |
[^abc] | NOT a, b, or c | [^0-9] → non-digit ✅ |