The GitButler CLI: Scott Chacon, GitButler

GGitButler
Computing/SoftwareSmall Business/StartupsInternet Technology

Transcript

00:00:00Welcome, so I'll do a quick demo if you guys don't know get Butler get Butler is a new version control tool
00:00:07We've been working on for a couple of years. We've stolen a lot of shit from JJ
00:00:10So if you guys use jujitsu, we've taken a lot of a lot of stuff from you
00:00:16Anyways, if you guys haven't used get Butler it is a version control tool
00:00:19It's a GUI generally
00:00:21but we're working on a CLI and I wanted to show off some of the CLI stuff since you guys all work on get and
00:00:26get has an interesting CLI and
00:00:29We have some some concepts that we stole from jujitsu as well
00:00:33But there's some new stuff that I think are pretty cool
00:00:36So I wanted to show it to you so I can get some ideas kind of for what would be super cool
00:00:40So yeah, I'll go over these things
00:00:43so
00:00:46There's a couple of different. So the command line tool is called but
00:00:49Since I've been telling dad jokes. I feel like this is somewhat appropriate
00:00:52You can run but status. This is sort of like a short log
00:00:57So if you guys have used sapling or jujitsu and and do the log
00:01:00Well, we'll show the files that are modified on disk
00:01:05From your working directory from sort of the target branch
00:01:08But we'll also show sort of the commits that you have, right?
00:01:11So you can also say but status - F and it will show you sort of the files that were modified in each of the commits
00:01:18If you're running the the get better see a GUI you can you can kind of see your lanes and stuff like that
00:01:23But there's a lot of cool things about get Butler the git can't do so we can do for example this nice short short log type
00:01:29thing
00:01:30but and and you know
00:01:32We can do sort of a log generally that says like are these commits local or they so this is similar to sort of a short
00:01:39log
00:01:40In in whatever and we can create new branches
00:01:44So if I say sort of status right I can see that so I'm doing a Twitter clone here
00:01:50So I have a couple of branches one is sort of stacked on top of the other
00:01:52Which is the thing that get kind of can do if you have like update ref
00:01:56Set right that will sort of rewrite your refs when you're doing rebasing or something like that
00:02:00But we do a little more naturally, right?
00:02:03So we we automatically sort of update your refs and and you can change stuff and whatever in the rebase will track that
00:02:09But we can also do
00:02:11Parallel branches so we can have more than one branch applied at a time. And so what I will do here. Oh
00:02:23Is create a new branch and
00:02:26Then run it again and I have sort of this this new branch that is parallel to the other branches that I'm doing, right?
00:02:33And what I can do is I can go into that branch and I can start sort of assigning stuff committing stuff
00:02:39So we'll see that next
00:02:41The other kind of cool thing that we can do is we have multiple staging areas
00:02:45So each of the stacks that you have has its own staging area so you can say
00:02:51Rub rub is the command you can say rub like KU for this file here, right and you can say put it into ZA and
00:02:58It sort of assigns it to that particular staging area if I wanted to assign something to this
00:03:04It gives you these sort of short codes, right and so you can say okay
00:03:12This one's assigned here and this one's assigned here
00:03:15And if I commit them then I can commit them into sort of either of these these branches at the same time
00:03:21So let's take a look at this. We can see this is committed here or this is a sign here so I can say
00:03:27but commit - oh
00:03:30And it commits it here, right
00:03:40So now this file is in this in this commit and the nice thing too is that this is all get right so I can also
00:03:48say
00:03:50This right it actually creates a git commit I can push that branch and whatnot
00:03:57but
00:03:59Yeah, so I can assign two branches or I can just say but commit and it will do everything that's unassigned and whatever the target
00:04:07Is so I can say which which branch I wanted to sort of commit new new stuff, too
00:04:11And so we came up with this term called rubbing
00:04:14I've told a bunch of people about Caleb who's been drinking all night and is not here
00:04:18Now if he comes in we should all stand up and give him a round of applause
00:04:21But he came up with this this term called rubbing which is essentially taking two things and putting them together and figuring out from what?
00:04:28They are so if you've done minecraft or whatever and have sort of the crafting table
00:04:32You know the concept of this where you know
00:04:34You take this and this and put it together and it creates something new and kind of more interesting, right?
00:04:38And so there's a whole bunch of things that you can do with the but CLI to rub stuff together with but rub
00:04:45So I'll show a couple of different things we can do we can assign stuff which I showed right you can assign an uncommitted or
00:04:52Modified file into a branch, but you can also sort of unassigned stuff. So there's this sort of special mode here zero zero
00:05:01Where I can say but rub
00:05:05You know this whole commit for example
00:05:07To zero zero and
00:05:11It uncommits that right? So it essentially does sort of a reset to like soft
00:05:17from that commit I can also amend stuff so I can say rub le r
00:05:24y
00:05:27RV boy, I need my reading glasses now. I'm pretty old to
00:05:32SW which is which is our sorry actually to
00:05:35One one W. Let's do that one
00:05:38Is it IW? Thank you
00:05:41oopsie
00:05:44Is that an I
00:05:48Sorry
00:06:02And
00:06:04It commits it into that I can do
00:06:10Rub I
00:06:14Can uncommit stuff?
00:06:16Right, I can squash stuff. So if I want to do this commit in this commit I can do but rub
00:06:22J e GE
00:06:25And it it squashes those commits together. I can yeah uncommit move stuff around
00:06:32Like essentially whatever you think it would do if you combine two things, right?
00:06:37It will it will do that thing and if you combine something to the unassigned changes, it will essentially undo it, right?
00:06:42And so you can even actually I can't remember if this actually works or not
00:06:48So you can also move files around right so
00:06:53J 8 2
00:07:02And
00:07:03it essentially takes the file from that commit and then
00:07:07Undoes it from that commit and then moves it into the commit underneath it, right?
00:07:11And so what's interesting about that is not that it's undoable in get but that it's relatively difficult to do in get right like to undo
00:07:19Individual commits somewhere or to move files between commits or to amend sort of a file into a commit three commits down
00:07:27right, like you can do it in get like you can do sort of a
00:07:31Temporary, you know fix up commit and auto squash or something like that
00:07:34But it's quite nice to just be able to kind of rub stuff around and kind of move the the content where you want it to
00:07:40Be and to have multiple multiple branches simultaneously
00:07:43So the other thing you can do with this is you can split commits relatively easily. So we also have this but new
00:07:51command so if I wanted to say
00:07:54but new
00:07:56H e then it will
00:07:59Create a new blank sort of commit there that has nothing in it
00:08:03Right. So this is sort of jujitsu style where you can create a new commit that has nothing in it
00:08:08And then I can sort of rub files into it if I wanted to so I could say
00:08:12Take this file
00:08:15Zero
00:08:23I take
00:08:29It moves this file into this new one and then I can say describe
00:08:32What was that X you see
00:08:45How could I
00:08:56Status - F status files. So it shows the files that are in each commit rather than so but ST
00:09:02but status just shows you the commits and
00:09:04But status - F shows you the files within each one so you can you can kind of move them around with the rubbing
00:09:11So yeah, so there's new and described and then the last thing is marking so this is very JJ style as well
00:09:16If anybody uses jujitsu, you can mark a commit which marks it as a target
00:09:21So everything then it sees it will put into that commit and so you can mark
00:09:25It's actually kind of an interesting thing, right so I can say
00:09:29But new - M or I can mark I can say but mark
00:09:33Z a and
00:09:35It will mark this and you can see that it already took the thing that was uncommitted and put it in into that into that
00:09:42Lane and
00:09:44Then I can commit stuff or I can also mark
00:09:47like a specific commit
00:09:56Oh that is a branch, I'm sorry
00:09:58And so it marks a specific commit and then if I like echo new
00:10:07Then it takes that in it automatically commits it to that commit, right
00:10:15So this is interesting because it's a stacked branch and it has several commits and it anything that I'm doing now
00:10:21It's automatically like amending a commit three commits down into a stack branch, right?
00:10:26And so I can it's sort of like the way that JJ does something where you do like JJ new and you start working
00:10:31It's just automatically sort of amending the last commit you do
00:10:33except you can mark essentially any commit and
00:10:36Keep working and it'll try to keep working on that commit and then you can unmark it whenever you want to
00:10:41right
00:10:44Anyways, so yeah, this is some of the fun stuff that we're working on
00:10:48I find it really nice to sort of be able to work on this
00:10:52The other thing that we do also kind of stolen from JJ is an oplog
00:10:56So this is something that we've had for a long time
00:10:59So if you've used the get better thing, there's a tab that says here's all the operations that we do
00:11:03But every time that I'm running something it does sort of you know
00:11:06an operations history and I can see everything that that get brother is done and I can restore to any of these or I can say
00:11:12like
00:11:13undo
00:11:14oops, if I spell it right I can say undo and it undoes the operation and puts my working directory back and my status back to
00:11:20Wherever it was before or I can say
00:11:22restore
00:11:24to sort of any of these Shaw's
00:11:26Oopsie
00:11:29And
00:11:33It resets my working directory in my my branches and everything that I had back to what it was before
00:11:38So this is actually it's kind of interesting to do a demo this way because I can create a scenario
00:11:44That I know works right and then be able to restore back to it and start sort of the the scenario back over again
00:11:50but obviously it's very nice to be able to say, you know what actually I didn't really want to do that or I got into a
00:11:54Conflict area or whatever. So just undo that and let me let me keep working
00:11:58So yeah, that's it. Oh and the other thing is that all of the commands have JSON output so you can say but - J
00:12:06Or - jason and run any of the commands and it'll give you the same data, but it'll give you in JSON
00:12:11So if you want to script something it's much nicer than having like a porcelain output of git or something
00:12:15like you can just pull that in or you can run it through jq and find like a specific entry or something like that and
00:12:21Be able to sort of script the the CLI a little bit nicer
00:12:24So that's it. Thank you very much

Key Takeaway

GitButler CLI introduces a high-level workflow for Git that simplifies complex operations like parallel branch management, cross-commit file movement, and state restoration through intuitive commands.

Highlights

Introduction of GitButler as a next-generation version control tool with a focus on its new Command Line Interface (CLI) named "but".

The concept of "Parallel Branches" which allows users to have multiple branches applied and active in the working directory simultaneously.

The "but rub

Timeline

Introduction to GitButler and the 'but' CLI

Scott Chacon introduces GitButler as a new version control tool that has been in development for several years. While primarily known as a GUI, this demo focuses on the emerging Command Line Interface called 'but'. He acknowledges that several concepts were inspired by other tools like Jujutsu (JJ) and Sapling. The 'but status' command is demonstrated as a superior alternative to the standard git log, showing modified files and local commits clearly. This section establishes the project's goal of making Git interactions more natural and informative for developers.

Parallel Branches and Multiple Staging Areas

The speaker demonstrates one of GitButler's standout features: the ability to work on parallel branches at the same time. Unlike standard Git where you are usually on one HEAD, GitButler allows multiple stacks to be applied to the working directory simultaneously. Each of these stacks maintains its own independent staging area, identified by short codes. Chacon shows how to assign specific file changes to different branches and commit them individually or collectively. This workflow enables developers to handle multiple logical changes without the constant overhead of context switching or stashing.

The 'But Rub' Command and Commit Manipulation

This section introduces 'rubbing,' a term coined by collaborator Caleb to describe the process of combining or moving data between entities. The 'but rub' command acts as a powerful Swiss Army knife for manipulating the commit history. Users can squash commits together, uncommit files back to the staging area, or move specific files between different commits in a stack. Chacon highlights that while these operations are technically possible in Git via complex rebasing, GitButler makes them trivial and intuitive. The metaphor of a Minecraft crafting table is used to explain how two items are 'rubbed' together to create a new result.

Advanced Commit Targeting and Marking

The demo moves into advanced commit creation using 'but new' to create blank commits, similar to the Jujutsu workflow. A key feature discussed is 'marking' a commit, which sets it as the active target for all subsequent changes in the working directory. When a commit is marked, any file edits are automatically amended into that specific commit, even if it is several layers deep in a stack. This removes the need for manual 'fixup' commits and subsequent autosquashing. Chacon emphasizes how this allows for a fluid, continuous development process where changes go exactly where they belong in the history.

Operation Logs, Undo, and JSON Scripting

In the final segment, the speaker showcases the Operation Log (oplog), which records every action taken within the tool. This enables a powerful 'undo' command that can revert the working directory and branch states to any previous point in time. This safety net is particularly useful for recovering from merge conflicts or accidental deletions during a demo. Additionally, Chacon reveals that every command supports a '-j' or '--json' flag for structured output. This feature is intended to make the CLI highly scriptable and friendlier for power users who want to parse data with tools like jq.

Community Posts

View all posts