Workspace Branch
What is the `gitbutler/workspace` branch and merge commit it points to? Also, why do we need it?
If you run some normal Git commands (like git log) while in GitButler mode, you'll see a few special branches that GitButler maintains behind the scenes. The one that most people get confused by is the gitbutler/workspace commit.
There are a few different reasons that we need it, so let's take a quick look.
If you run a normal git log on a GitButler managed repository, you will see something like this:
That first commit is a merge commit that we rebuild as you modify branches in GitButler. The reason that it exists is mainly because if you have more than one branch applied in your workspace, when other tools run git status, it will look strange, since Git has no concept of having several branches applied at once.
Status, Diff and Log
To keep Git command output for things that look at the index and HEAD (such as status or diff) somewhat sane, we modify your index to look like the union of all the committed states of all your applied virtual branches. This makes git diff and git status behave more or less like you would expect.
For instance, if you have two files on Branch A and two files on Branch B, then git status will simply list four files as modified.
If you run git log, the first commit should be our custom commit message and the tree of that commit is the union of all the committed work on all your applied virtual branches, as though they were all merged together into one (something stock Git can understand).
Committing, Branching, Checking Out
However, if you try to use something that writes to HEAD, like git commit or git checkout, then you might have some headaches. For this reason, we install custom Git hooks for pre-commit and post-checkout that will protect this from happening.
If you try to commit when in GitButler managed mode, the pre-commit hook should disallow it and tell you how to fix it.
If you want to get out of this mode, you can follow any of those instructions. The easiest is running but teardown, but simply switching directly to a normal Git branch will also do the trick.
Last updated on