how-to-manage-multiple-flutter-versions-with-git-worktrees-and-z

How to Manage Multiple Flutter Versions with Git Worktrees and ZSH

Safety Notice

This listing is imported from skills.sh public index metadata. Review upstream SKILL.md and repository scripts before running.

Copy this and send it to your AI assistant to learn

Install skill "how-to-manage-multiple-flutter-versions-with-git-worktrees-and-z" with this command: npx skills add rodydavis/skills/rodydavis-skills-how-to-manage-multiple-flutter-versions-with-git-worktrees-and-z

How to Manage Multiple Flutter Versions with Git Worktrees and ZSH

If you have been using Flutter for any length of time then you probably have needed to use multiple flutter versions across multiple projects.

In the past I used to use FVM (Flutter Version Management) which is similar to NVM (Node Version Manager) in the JS world.

I wanted a solution that only relied on Git, and started using worktrees to manage the Flutter channels.

Download the SDK 

Check out the flutter repo in a known directory, in this case I will download it to ~/Developer/ :

git clone https://github.com/flutter/flutter ~/Developer/flutter

Add Flutter Channels 

Now we can add the branches we want to track:

cd ~/Developer/flutter git checkout origin/dev git worktree add ../flutter-stable stable git worktree add ../flutter-beta beta git worktree add ../flutter-master master

We need to checkout the dev channel to allow us to create the worktree for the master branch. This will keep the flutter  directory separate so we can work on PRs and apply local changes.

After this runs we should have 4 directories: flutter , flutter-master , flutter-beta  and flutter-stable .

Add ZSH Alias for each Channel 

Now we need a way to reference each SDK on the fly with an alias in ZSH. Add the following to ~/.zshrc :

alias flutter-master='/Developer/flutter-master/bin/flutter' alias dart-master='/Developer/flutter-master/bin/dart'

alias flutter-beta='/Developer/flutter-beta/bin/flutter' alias dart-beta='/Developer/flutter-beta/bin/dart'

alias flutter-stable='/Developer/flutter-stable/bin/flutter' alias dart-stable='/Developer/flutter-stable/bin/dart'

Conclusion 

After reopening the terminal, you can verify it is working by running (or add any channel we added above):

flutter-master doctor dart-master --version

flutter-stable doctor dart-stable --version

You can update any of the channels by navigating to the directory of the worktree for the given channel and pulling changes like any other Git repo.

cd ~/Developer/flutter-master git checkout origin/master

Git worktrees are just a way to checkout multiple branches as separate folders instead of needing to stash changes.

Source Transparency

This detail page is rendered from real SKILL.md content. Trust labels are metadata-based hints, not a safety guarantee.

Related Skills

Related by shared tags or category signals.

General

flutter-control-and-screenshot

No summary provided by upstream source.

Repository SourceNeeds Review
General

install-flutter-from-git

No summary provided by upstream source.

Repository SourceNeeds Review
General

how-to-build-a-native-cross-platform-project-with-flutter

No summary provided by upstream source.

Repository SourceNeeds Review
General

how-to-build-a-webrtc-signal-server-with-pocketbase

No summary provided by upstream source.

Repository SourceNeeds Review