Skip to main content

Overview

Learn Git Branching allows you to share permalinks - special URLs that encode Git commands or repository states. This makes it easy to share examples, demonstrations, or specific scenarios with others. Permalinks are useful for:
  • Teaching: Share specific Git scenarios with students
  • Documentation: Embed interactive examples in tutorials
  • Debugging: Share a problematic repository state for help
  • Demonstrations: Show Git concepts in presentations
  • Collaboration: Share interesting Git puzzles with your team
Learn Git Branching supports several types of permalink parameters.

Command Parameter

Execute arbitrary commands when the page loads using the command URL parameter.

Basic Usage

https://learngitbranching.js.org/?command=git%20commit;git%20commit
This URL will:
  1. Load the application
  2. Automatically execute git commit; git commit
  3. Display the resulting repository state

Creating Command URLs

To create a command URL:
  1. Use the command parameter
  2. URL-encode your commands (spaces become %20, semicolons separate commands)
  3. Optionally add NODEMO to skip the intro dialog
Example without URL encoding:
command=git commit;git branch feature;git checkout feature
Properly encoded:
command=git%20commit;git%20branch%20feature;git%20checkout%20feature
Most programming languages and tools have functions to URL-encode strings automatically. In JavaScript, use encodeURIComponent().

Complete Example

https://learngitbranching.js.org/?NODEMO&command=git%20commit;git%20commit;git%20branch%20feature;git%20checkout%20feature;git%20commit;git%20checkout%20main;git%20merge%20feature
This demonstrates a complete branch-and-merge workflow. Generate a permalink for the current repository state:
share permalink
# or simply
share
This outputs a URL that will recreate your exact current repository state using the importTreeNow command. Example output:
Here is a link to the current state of the tree:
https://learngitbranching.js.org/?NODEMO&command=importTreeNow%20%7B%22branches%22...%7D
The share permalink command exports your entire repository structure as JSON, then encodes it in the URL. The URLs can be quite long for complex repositories.

Level Parameter

Link directly to a specific level:
https://learngitbranching.js.org/?level=intro1
This immediately starts the specified level when the page loads. Level name examples:
  • ?level=intro1 - Introduction to Git Commits
  • ?level=intro2 - Branching in Git
  • ?level=rampup1 - Detach yo’ HEAD
  • ?level=remote1 - Clone Intro
Use this to bookmark levels you’re working on or share specific challenges with learners.

Gist Level ID

Share custom levels using GitHub Gists:
https://learngitbranching.js.org/?gist_level_id=a84407351f9c9f0cb241
This loads a custom level from the specified GitHub Gist ID. See Level Builder for details on creating custom levels.

Demo Parameters

Several demo modes showcase specific features:

Standard Demo

https://learngitbranching.js.org/?demo
Runs a sequence of commands demonstrating basic Git operations.

Remote Demo

https://learngitbranching.js.org/?remoteDemo
Demonstrates remote repository operations (push, pull, fetch).

NODEMO Parameter

Skip the introductory dialog and go straight to the sandbox:
https://learngitbranching.js.org/?NODEMO
Always include NODEMO in permalinks you share, so recipients aren’t greeted with the intro dialog.

Locale Parameter

Set the interface language:
https://learngitbranching.js.org/?locale=zh_CN
Supported locales include:
  • en_US - English
  • es_AR, es_MX, es_ES - Spanish variants
  • zh_CN, zh_TW - Chinese variants
  • ja - Japanese
  • de_DE - German
  • fr_FR - French
  • ko - Korean
  • ru_RU - Russian
  • And many more!

Combining Parameters

You can combine multiple parameters in one URL:
https://learngitbranching.js.org/?NODEMO&locale=ja&command=git%20commit;git%20branch%20feature
This URL:
  • Skips the intro dialog (NODEMO)
  • Sets Japanese language (locale=ja)
  • Executes two commands (command=...)
Parameters are separated by & in the URL. The first parameter uses ?, subsequent ones use &.

Practical Examples

Example 1: Teaching Branch Management

Create a scenario showing a feature branch workflow:
https://learngitbranching.js.org/?NODEMO&command=git%20commit;git%20branch%20feature;git%20checkout%20feature;git%20commit;git%20commit;git%20checkout%20main;git%20commit;echo%20%22Now%20try%20merging%20feature%20into%20main!%22
This sets up a diverged history and prompts the learner to merge.

Example 2: Demonstrating Rebase

Show the difference between merge and rebase:
https://learngitbranching.js.org/?NODEMO&command=git%20commit;git%20commit;git%20branch%20bugfix;git%20checkout%20bugfix;git%20commit;git%20checkout%20main;git%20commit;git%20checkout%20bugfix;git%20rebase%20main

Example 3: Remote Repository Setup

https://learngitbranching.js.org/?NODEMO&command=git%20clone;git%20commit;git%20commit;git%20push
Demonstrates cloning and pushing to a remote.

Example 4: Share a Complex State

Use share permalink in the application to generate a URL for any repository state:
# Build your scenario
git commit
git branch feature1 
git branch feature2
git checkout feature1
git commit
git checkout feature2  
git commit
git checkout main
git merge feature1

# Generate the permalink
share permalink
Copy the generated URL to share this exact state.

Best Practices

Always use NODEMO - Include ?NODEMO in shared links to avoid showing the intro dialog to recipients.
Add explanatory echo commands - Use echo "message" to provide context:
command=git%20commit;git%20commit;echo%20%22Try%20creating%20a%20branch!"
Test your links - Always test permalink URLs before sharing to ensure they work as expected.
Use URL shorteners for long links - Repository state URLs can be very long. Use services like bit.ly or tinyurl to create shorter, more shareable links.
Add delays for demonstrations - Use the delay command in sequences to pace automatic demonstrations:
command=git%20commit;delay%202000;git%20commit;delay%202000;git%20branch%20feature

URL Encoding Reference

Common characters that need encoding:
CharacterEncodedUsage
Space%20Between command words
Semicolon;Separates commands (no encoding needed)
Quote%22For strings with spaces
{%7BJSON structures
}%7DJSON structures
[%5BJSON arrays
]%5DJSON arrays
Semicolons (;) do NOT need to be encoded when separating commands in the command parameter.

Sharing on Social Media

When sharing on platforms like Twitter or LinkedIn:
  1. Use a URL shortener (the full URLs are too long)
  2. Add context explaining what the link demonstrates
  3. Consider creating a demo GIF or screenshot to accompany the link
Example tweet:
Here's an interactive demo of git rebase vs merge:
[shortened URL]

Try it yourself and see the difference!

Embedding in Documentation

You can embed Learn Git Branching links in:
  • Markdown documentation (as regular links)
  • README files
  • GitHub wiki pages
  • Blog posts
  • Online course materials
Markdown example:
Try this [interactive branch merge example](https://learngitbranching.js.org/?NODEMO&command=git%20commit;git%20branch%20feature).

Troubleshooting

URL Too Long

Problem: Repository state URLs generated by share permalink are very long. Solutions:
  • Use a URL shortener service
  • Simplify the repository state before sharing
  • Use export tree and import tree instead for very complex states
  • Create a custom level with Level Builder and use a gist URL

Commands Not Executing

Problem: The URL loads but commands don’t run. Check:
  • Ensure commands are properly URL-encoded
  • Verify semicolons are separating commands correctly
  • Check that the command parameter is spelled correctly
  • Test individual commands in the sandbox first

Special Characters Issues

Problem: Commands with quotes or special characters fail. Solution: Properly encode special characters:
// JavaScript example
const commands = 'echo "hello";git commit';
const encoded = encodeURIComponent(commands);
const url = `https://learngitbranching.js.org/?NODEMO&command=${encoded}`;

Alternative Sharing Methods

Export/Import Tree

For very complex states, use the export/import workflow:
  1. In the application:
export tree
  1. Copy the JSON output
  2. Share the JSON with others (via gist, pastebin, etc.)
  3. They can import it:
import tree
# Paste the JSON

Custom Levels

For reusable scenarios, create a custom level:
  1. Use Level Builder to create the level
  2. Post the JSON to a GitHub Gist
  3. Share the gist URL: ?gist_level_id=YOUR_GIST_ID
This is better than command URLs for:
  • Scenarios you’ll share repeatedly
  • Interactive challenges with specific goals
  • Teaching materials

Next Steps

  • Learn about Level Builder for creating sharable challenges
  • Explore Git Golf for optimizing command sequences
  • Practice in Sandbox Mode before creating permalinks
  • See Levels for challenge ideas to share

Build docs developers (and LLMs) love