What is the proper CLI workflow? Why does commit not automatically pick up (just) staged files? #14594
|
With
I've been using GitButler CLI for a while now and I do:
This all works, but it feels slightly wonky to me. I tend to have to work on multiple things at the same time so GitButler's way of having multiple active branches is great for me, and so far I've really enjoyed many of the features GitButler provides. However with my way of working I rarely want to commit all current changes to the same branch so the default of I can understand defaulting to committing all unstaged files when nothing is staged, but doing so when things are staged has bitten me a couple of times already. And maybe this is just me still being on Git-brain instead of GitButler-brain, so if there is an improvement to my way of working I'll be glad to hear it. Thanks. |
Replies: 4 comments
|
Your read is reasonable: this isn’t just “Git-brain”. In GitButler, For the workflow you described, the safer pattern is: but branch new my-branch
but stage --branch my-branch
but commit --only my-branch
but pushor, with a message: but commit --only -m "My commit message" my-branchThe surprising part is exactly what you called out: once you have explicitly staged changes, that is a strong signal of intent. Having The current behavior is mostly optimized for the “commit everything currently assigned to this branch” flow, but the CLI could probably make this clearer or safer. A few possible improvements would be: default to staged-only when staged changes exist, warn before including unstaged/unassigned changes, or add a config option for Git-style commit semantics.
If my answer solved your problem, you can click answered the question. I'm really here to help, and along the way I'm also collecting Galaxy Brain badges haha 😆 |
|
Thanks for sharing! To me, it feels like the butt CLI isn't very well tuned right now, especially if staging is involved, and I'd think this will change. Here there is a bit of a split-brain going on where This isn't a satisfactory answer as there is a lot of guessing involved, but I hope when David chimes in it will all become clearer. |
|
I am also getting the feeling that Can anyone elaborate on how to use it correctly? The user guide gives the mechanical details but doesn't really explain what it is for. So far, every time I wanted to "stage" something I just committed it. Am I missing something here? What is the added value? |
|
There is an ongoing internal discussion about the future of staging in GitButler. So while I cannot say anything for certain, I think it is very likely that staging as a feature will be removed from the products. This includes the CLI, the TUI, and our new in-development Electron-based GUI. It likely wont be removed from the Tauri app because the Electron version is the future. The idea is that if it's easy to pick what and where to commit, and the commits are easy to change after the fact, then there isn't a need for staging. It becomes an unnecessary holdover from how the git CLI expects you to work. You can just commit some changes to one branch and some other changes to another branch. There is no need to first stage and then commit. You can later massage the commits (squash/move/reword/etc.) to get them ready for review. The new commands that @Byron hint at are being designed with this in mind. They will not support staging. Personally, my workflow is to make lots of small "work-in-progress" commits to my parallel branches and then squash them into one commit per branch before opening a PR. Sometimes I also start with one empty commit per branch that I keep amending with new changes. It depends on the day. |
There is an ongoing internal discussion about the future of staging in GitButler. So while I cannot say anything for certain, I think it is very likely that staging as a feature will be removed from the products. This includes the CLI, the TUI, and our new in-development Electron-based GUI. It likely wont be removed from the Tauri app because the Electron version is the future.
The idea is that if it's easy to pick what and where to commit, and the commits are easy to change after the fact, then there isn't a need for staging. It becomes an unnecessary holdover from how the git CLI expects you to work. You can just commit some changes to one branch and some other changes to another branch…