Intro to the GitButler CLI

GGitButler
์ปดํ“จํ„ฐ/์†Œํ”„ํŠธ์›จ์–ด์ฐฝ์—…/์Šคํƒ€ํŠธ์—…AI/๋ฏธ๋ž˜๊ธฐ์ˆ 

Transcript

00:00:00Hello everybody. My name is Scott Chacone. I'm the CEO of Git Brother.
00:00:02I'm going to do a quick demo of the new Git Brother CLI.
00:00:06So if you're familiar with the command line,
00:00:08if you want to be able to use Git Brother programmatically,
00:00:11the new Git Brother CLI is a pretty cool thing to do.
00:00:14So let's go ahead and get started. Okay. So we're going to start with a repository.
00:00:18I have this little Rust project, um,
00:00:20and we're going to start going through sort of the workflow of the Git Brother CLI.
00:00:23It's essentially a drop-in replacement for Git. So once this is installed,
00:00:27you have the "but" command. This is going to be your main interface instead of Git.
00:00:32You can run "but" or you can run "but" status. This is just short for that.
00:00:35And it will show you the status.
00:00:38So this is very similar to sort of the output of Git status.
00:00:41We can see that there's four sort of modified files.
00:00:44There's a couple that are untracked. There's a couple that have been changed.
00:00:47So some new files and some modified files, but the "but" output,
00:00:50the status will show you sort of just a list of four. These are changes, right?
00:00:55These are things that you have modified. Um, and so you can go ahead and commit them,
00:00:59however you want to. So what we're going to do, you can just run "but" commit.
00:01:02It will create a temporary branch. Um, actually let's go ahead and try that.
00:01:05And if we run "but" status again, we can see all of those changes are in one.
00:01:11We can also run "but" status dash F or dash dash files.
00:01:15It'll show you the files sort of that have been modified in this commit.
00:01:18But let's say that we don't actually want to commit all of those into one commit,
00:01:21right? Some of them are Clod related. One's a readme.
00:01:24One's actually changes to the thing. These are really three separate changes,
00:01:28right? So we want these to be three separate commits. So let's undo that.
00:01:31We can uncommit a commit by running
00:01:36uncommit. And now we're back. We still have this sort of temporary branch here.
00:01:40We can delete that if we want to. Um, but let's just go ahead and reuse it.
00:01:44I'm going to reword this. I'm going to call the branch Clod stuff.
00:01:48And now I have a new branch here and I can stage stuff to it,
00:01:53sort of like get ad. So we can say, but stage G zero and H zero.
00:01:58These are the sort of the short codes for these.
00:02:01We can also type out the entire path if you want to,
00:02:04but we try to make it fairly easy to do this quickly. And now if I look,
00:02:08these are staged to the Clod stuff branch and I can commit with dash O,
00:02:12which means only the stuff that's staged. If I run commit,
00:02:15it will commit everything that's staged to this and everything that's on stage.
00:02:18So we'll, that'll make more sense when we have more branches,
00:02:20but let's go ahead and commit this. So now we have a branch with a commit on it
00:02:25and a couple of unstaged changes.
00:02:28Now this is where it gets kind of interesting because unlike Git,
00:02:31let's say that I want to put this read me,
00:02:34I want to commit this read me and I want to push it up and have a PR open for it.
00:02:37I would normally have to, if I'm on the sort of Clod branch here,
00:02:41I'd have to stash this branch, add this, read me, commit it,
00:02:44push it up for a pull request.
00:02:45But here what we can actually do in get brother is we can have parallel branches
00:02:50so I can save but branch new as he read me and you can see I have a new branch
00:02:55that comes off and I can stage that file.
00:03:00I can commit that file.
00:03:01If I look at the files that are changed, right?
00:03:07I have this commit that has these two Clod things.
00:03:09I have this read me with this one read me change. Again,
00:03:11I can do the same thing if I'd like to. I can say commit
00:03:17-c is create so I can create a new branch this way and I want to say, actually,
00:03:21let's see what the, what we've actually changed here. I kind of forgot. Oh,
00:03:25this read command. Okay.
00:03:27And that'll take the last uncommitted thing or anything that's uncommitted at
00:03:32this point and it'll let you create a new branch and commit it to that.
00:03:35And now we can see we have three branches.
00:03:38They're all independent of each other.
00:03:39They're all of those changes are still in our working directory.
00:03:42We haven't actually changed our working directory at all.
00:03:44We're just sort of creating commits in memory.
00:03:46And now I can run but push and it will say, what do you want to push?
00:03:50Do you want to push all of these? They each have one on push commit on them.
00:03:53Do you want to just push one of them? Let's only push the read me.
00:03:57Let's say that's the only one that we think is sort of ready right now.
00:03:59And we can just choose that one and it will push that.
00:04:02And if we look at our status again,
00:04:03we can see that this one is pushed just by the status here.
00:04:06And these ones are local only.
00:04:08So Git Builder has a lot of power in working with multiple branches
00:04:11simultaneously. Um, but it can also do stack branches.
00:04:13So let's look at an example of creating a new thing
00:04:17based on one of the commits that we've done,
00:04:19creating a stack branch off of it.
00:04:20So we can merge the bottom one and continue to work on the top one.
00:04:23Let's say that we want to create a stacked branch.
00:04:26We want this read command to be reviewed and merged in,
00:04:30but we want to be able to keep working on it.
00:04:32This is a good point for doing a stacked branch rather than an independent branch
00:04:35because there is a dependency. So the way that we do that is we can say,
00:04:38get branch new dash a as an anchor point,
00:04:42which is this SC read command. And we can say SC read more.
00:04:46And now if we look at this,
00:04:48we can see that we have this branch that's stacked on top.
00:04:50So let's go ahead and edit this.
00:04:52And we can see that this is taking 10 messages and showing them.
00:04:57Let's go ahead and do that as 20 messages. And we'll change this too.
00:05:02And we can see that we have this change and there's this lock icon because it's
00:05:09changing a file that we've already committed somewhere.
00:05:11And so it's locked to a specific commit.
00:05:13We can really only commit it on top of this because it's changing code that was
00:05:16introduced there. We can see what's changed with the diff command,
00:05:20which is a nice way of sort of seeing what hunks have been changed and we can go
00:05:25ahead and commit that. Okay.
00:05:28Now just to see how easy it is to sort of change commits around as well,
00:05:32what I'm going to show how to do,
00:05:33we'll do status dash F can see all of the sort of files.
00:05:37Let's go ahead and share this. We already saw push,
00:05:40which will push to the remote that you have,
00:05:42but we can also say PR which opens up a pull request. So we can say,
00:05:46which of these do we want to open pull requests for?
00:05:48So let's go ahead and open pull requests for all of them.
00:05:50So it's going to open up an editor for each one and say,
00:05:54what do I want the PR description to be? So I'll just keep it easy.
00:05:57And now we have all of these PRs. Now that we've opened up the PRs,
00:06:01we can actually see these numbers up here. Number one, number two,
00:06:04these are the PR numbers and the messages.
00:06:06We just kind of use the same ones each time.
00:06:08We can also see with the dash V command,
00:06:10which is verbose the URLs for each of these.
00:06:12So let's go ahead and look at one.
00:06:14So this is the PR that changes the read me and we can see that it just has the
00:06:18one commit and it just has the change to that one read me file. So it's isolated.
00:06:23This is the stacked one.
00:06:24And we can see if we look at one of these that what it's done is it's opened a
00:06:28stack. So the first one,
00:06:30this is the bottom PR is targeting main, right from this one.
00:06:35And the second one, which we can jump to here is targeting the first one.
00:06:39So it actually does a stacked branch properly.
00:06:41So now let's see what happens when we integrate something.
00:06:43Let's go to this pull request, this read me one. We can say, okay,
00:06:46this looks good. I'll go ahead and merge it in. This is now upstream.
00:06:49And if we run, but pull dash dash check that will check.
00:06:55We can also run, but fetch it. We'll sort of run this for you.
00:06:57And it will also fetch in the background every once in a while.
00:07:00You might have seen this when we're running some commands.
00:07:02It says I kicked off a background thing, but we can see that this one has been
00:07:06integrated. We can see it integrated upstream. And so when we run get pull,
00:07:10what it's going to do is it's going to get that new information.
00:07:13It's going to rebase our other branches and it will pull out this integrated
00:07:16branch. So we can see that this has been removed locally.
00:07:19So now when we look that one is done,
00:07:22these ones have been rebased so that they're updated to the new ones and we can
00:07:25push them back up if we'd like to do that. And now at any time,
00:07:29if you want to go back to just doing stuff with Git, you can say, but tear down,
00:07:33and that will go ahead and choose one of your branches.
00:07:36And you can see that it'll just choose the first branch that you were on,
00:07:39but you still have all of the branches that we were working on here.
00:07:43It's just that your own Git can only be on one. So now you're only on one again.
00:07:47So you can use set up and tear down to go in and out of get by the mode.
00:07:50If you want to work on multiple branches or just work with normal Git commit
00:07:55tooling. But again, even if we're in get by the mode, you can still use most,
00:08:00get commands. So you can say, get show on one of these. It's the same thing.
00:08:04You can say, get log, same thing, get logs, still works.
00:08:08All of these reading commands work fine. If show log all of these things,
00:08:13it's just committing that we're really sort of managing for you. In this case,
00:08:16you can also just directly check out a thing and get brother will see that and it
00:08:21will sort of remove everything that it was doing. And again,
00:08:24you should just be fine again.
00:08:26And the last thing that I'm going to show is that all of these commands have a
00:08:30dash dash Jason version. So if you want to run status with dash dash Jason,
00:08:34you can go ahead and do that. If you want to run show on a commit, for example,
00:08:41you can do that nearly all of the commands have a,
00:08:44and you can see all of the commands with, with, but help nearly all of these
00:08:48commands have a dash dash Jason or dash J option to them. Um,
00:08:52which means that you can easily script them actually even interestingly,
00:08:56you can do diff and it gives you sort of a Jason version of the diff, um,
00:09:00which I think is pretty cool.
00:09:01So that's a nice introduction to get brother and what you can do versus sort of
00:09:05what you can do and get. But again, you can drop this into any get repository.
00:09:08You can run, but set up, you can start doing all of these commands.
00:09:12You can have Jason alpha for stuff. You can manage multiple branches.
00:09:15You can manage stack branches. Um, you can do your,
00:09:17your sort of GitHub integration, PR management. Um,
00:09:20all of these things are just drop in, start running, but commands and it's fine.
00:09:24Anytime that you want to go back to get,
00:09:26even though most of the get commands still work in this environment, um,
00:09:29you can just tear it down or check out a branch and it will clean up everything
00:09:33for you. So go ahead and try it out today.
00:09:35You can go to get brother.com/cli and download it and start playing with it.
00:09:39Drop into our discord and let me know what you think. Thanks.

Key Takeaway

GitButler CLI introduces a powerful workflow for managing multiple parallel and stacked branches simultaneously without the traditional friction of stashing or context switching in Git.

Highlights

GitButler CLI (the "but

Timeline

Introduction and the 'but' Command

Scott Chacone, CEO of GitButler, introduces the new CLI tool designed for programmatic use within Git repositories. He demonstrates the 'but' command, which serves as a replacement for standard Git commands and provides an enhanced status view of modified and untracked files. The interface simplifies committing by automatically handling branch creation, though users can customize these actions. Chacone explains that while it mimics Git status, it groups changes into a more manageable list of 'modified things.' This section establishes the foundation of the GitButler workflow as an additive layer over traditional Git.

Branch Management and Parallel Workflows

The speaker demonstrates how to uncommit changes and organize them into specific branches using short codes for file staging. A major highlight is the ability to create parallel branches for different tasks, such as documentation and code changes, without using 'git stash.' This allows the developer to keep all changes in the working directory while logically separating them into different commits and branches. Chacone emphasizes that these branches are created 'in memory' without actually changing the physical working directory files. This approach solves the common friction point of having to jump between branches for small, unrelated updates like a README fix.

Stacked Branches and GitHub Integration

This segment covers the creation of stacked branches using the anchor flag, which is useful when a new feature depends on an unmerged commit. GitButler visually represents these dependencies and locks certain files to specific commits to maintain logical consistency. Chacone then demonstrates the 'but push' and 'but PR' commands, which facilitate pushing local changes to a remote server and opening multiple pull requests at once. The CLI opens a text editor for each branch to allow for quick PR description entry. This integration streamlines the transition from local development to the collaborative review phase on GitHub.

Integration, Rebasing, and Upstream Syncing

The demo shows how GitButler handles the integration of PRs once they are merged upstream on platforms like GitHub. By running a check or fetch command, the tool identifies that a branch has been merged and automatically removes it from the local workspace. Remaining local branches are automatically rebased against the updated main branch to ensure the developer is always working on the latest code. This automated cleanup and rebasing logic reduces the manual maintenance typically required when working with many short-lived branches. It ensures that the local 'virtual' state stays in sync with the remote repository's reality.

CLI Flexibility and Scripting with JSON

In the final section, Chacone explains how to exit the GitButler environment using the 'tear down' command, which returns the user to a standard Git state. He reassures viewers that standard Git commands like 'git log' and 'git show' continue to work perfectly while GitButler is active. A key technical feature highlighted is the '--json' flag, which is available for nearly all commands, including 'but status' and 'but diff.' This makes the tool exceptionally powerful for developers who want to build their own scripts or automation around GitButler's data. The video concludes with an invitation to download the tool and join the community discord for further discussion.

Community Posts

View all posts