Branching and committing
Create branches, commit selected changes, and stack dependent work with the GitButler CLI.
Now that your project is set up, you can create a branch and commit your first changes.
Create and commit on a branch
Start by inspecting the workspace:
but status shows the uncommitted area, applied branches and stacks, and the commits that haven't landed in your target branch.
If you have uncommitted changes and no branch yet, create the branch and commit in one command:
The -b option selects the branch. If user-bookmarks doesn't exist, GitButler creates it. Because the command doesn't include any change IDs, it commits all uncommitted changes.
If you omit -m, GitButler opens your configured editor for the commit message. In scripts, always pass -m or --no-message so the command doesn't wait for input.
Commit selected files or hunks
Use but diff to get IDs for the changes you want to commit:
The first token on each file line is its ID. A hunk ID has the form <file-id>:<hunk-id>, such as q3:5.
Pass the IDs as space-separated positional arguments:
That commits only changes q3 and w7. The other changes stay uncommitted.
To commit one hunk without committing the rest of its file:
Copy IDs from your current but diff output. Don't comma-separate IDs or use line ranges.
Work on parallel branches
Parallel branches hold independent work in the same workspace. Suppose user-bookmarks is applied and you start an unrelated liked-tweets change. Inspect the new changes, then commit them to another branch:
GitButler creates liked-tweets alongside user-bookmarks. Run but status to see both branches:
When more than one independent stack is applied, always use -b, --above, or --below to say where a commit belongs. GitButler refuses an untargeted commit when the destination is ambiguous.
Stack dependent branches
If the liked-tweets work turns out to depend on user-bookmarks, move that
branch above user-bookmarks to turn the two parallel branches into a stack:
Once you've authenticated with but config forge auth, publish the stack from its top branch:
GitButler pushes the stack and creates the missing reviews from the bottom upward. See Create stacked branches and pull requests for the full stacked-review workflow.
Last updated on