edgedb-cli icon indicating copy to clipboard operation
edgedb-cli copied to clipboard

`gel` should connect to the next available branch when `main` doesn't exist

Open NetOpWibby opened this issue 6 months ago • 2 comments

In my Gel projects, I like to have my database name and branch names be specific.

Gel expects there to be a main branch so running gel without parameters will always result in error. Here's my process:

gel instance create DATABASE_NAME
gel -I DATABASE_NAME branch create BRANCH_NAME
gel project init --server-instance DATABASE_NAME --link

gel --branch BRANCH_NAME
DROP BRANCH main;
\quit

Just like linking an instance will save it to my project, my desired default branch should be saved as well.

EDIT: I just learned about branch switch so this works:

gel instance create DATABASE_NAME
gel --instance DATABASE_NAME branch switch --create BRANCH_NAME
gel project init --server-instance DATABASE_NAME --link

Now I can run gel without params and automatically get connected to the instance and branch I want. Idk where this would go in the docs, maybe just refer people to this until gel understands .env files?

NetOpWibby avatar Jun 22 '25 01:06 NetOpWibby

In my Gel projects, I like to have my database name and branch names be specific.

That's totally fair, and instance names (what I'm assuming you mean by "database name"?) must be unique. Branch names on the other hand are a bit more like git branch names: there is often a main or trunk branch that is consider to be the "default" branch, and for Gel that's main.

I just learned about branch switch so this works

I'll think about how we can reenforce this in the docs, you've indeed figured out how to switch your project-linked instance branch, but probably hadn't really thought of it in exactly those terms.

maybe just refer people to this until gel understands .env files?

Gel already understands environment variables, so if you have environment variables in your project that you're using to configure your tooling but they're in .env files, I'd suggest using something like direnv, dotenvx, or sops. I don't think there is a 100% consistent agreed upon naming convention for .env that is environment aware across all tools, so I wouldn't personally rely on a .env file being picked up consistently.


I think there is another approach that might be useful here though. And it's not a CLI-specific thing, because the CLI is "just" a client, so this would apply to all clients. We could have a setting in gel.toml similar to git config init.defaultBranch that configures the fallback for each project. You could configure that as part of the gel project init flow.

scotttrinh avatar Jun 23 '25 14:06 scotttrinh

We could have a setting in gel.toml similar to git config init.defaultBranch that configures the fallback for each project

I'd love that.

EDIT: This seems relevant https://github.com/geldata/gel-cli/issues/1665

NetOpWibby avatar Jun 23 '25 17:06 NetOpWibby