B-branch is a tool that enhances Git branch management with a convenient git alias. Inspired by the talk So You Think You Know Git? by Scott Chacon, B-branch offers a more organized view of your branches, simplifying your workflow.
Traditional git branch commands sort branches alphabetically, making it hard to find recent ones. B-branch solves this by displaying branch information like the last commit date and commit differences with the upstream branch, all in a structured format.
Cross-Platform Support: B-branch runs on Windows, Linux, and macOS with no dependencies required when using the compiled executable. Download the latest release for free!
key benefits
- Quickly identify the branch you need.
- Access additional branch details not available with git branch.
- Enjoy reliable, high-performance, cross-platform support.
-
Branch information: Displays the branch name, the date of the last commit, the number of commits ahead or behind the upstream branch, and the branch description.
-
Branch description: Git offers the ability to add a description to a branch. B-branch displays this description in the output.
-
Pager interface: If the output is too large to fit on the screen, the output will be displayed in a pager interface. While in the pager interface.
q
: Quit the pager interface.j
ORDown Arrow
: Move down one line.k
ORUp Arrow
: Move up one line.f
ORSpace
: Move down one page.b
: Move up one page.g
ORHOME
: Move to the top of the output.G
OREND
: Move to the bottom of the output./
: Search for a string in the output.Escape
: Clear the search.
Let's say you have a git repository with a lot of branches. You want to remove the branches that are no longer needed.
git bb --no-contains "main;development" -q \
| awk '{print substr($0, 3)}' \
| xargs -I {} git branch -D {}
Important
This command will delete all branches that do not contain the strings "main" or "development". Be careful when using this command.
The ability to see the branch description is also a feature that is not available in the standard git branch
command. To add a description to a branch, use the following command:
git branch --edit-description
Note
Keep in mind that the description is stored in the .git/EDIT_DESCRIPTION
and does not support a description on multiple branches.
git bb [options]
-t, --track <String>
: Displays information about how many commits the specified branch is ahead or behind relative to its upstream branch.-q, --quiet
: Only displays the names of the branches without any additional information or formatting.-v, --version
: Shows the current version of theB-branch
tool.-s, --sort <String>
: Sorts the branches based on the specified criterion. Valid options are[date]
,[name]
,[ahead]
, or[behind]
.-a, --all
: Displays all branches, both local and remote.-n, --no-contains <String>
,"String1;String2;..."
: Filters the list to only show branches that do not contain the specified string. Valid options are<String>
OR"String1;String2;..."
.-c, --contains <String>
,"String1;String2;..."
: Filters the list to only show branches that contain the specified string. Valid options are<String>
OR"String1;String2;..."
.-r, --remote
: Includes remote branches in the output.-h, --help
: Displays the help message with information about all available options.-p, --print-top <Number>
: Prints the top N branches based on the specified sort criterion.
Download the latest release for free! In the release, you will find the compiled executable for Windows, Linux, and MacOS with an installation script.
Note
For full experience, download the latest version of the nerd-fonts and install it on your system.
We welcome contributions to B-branch! If you have suggestions or improvements, please adhere to the following guidelines when contributing to the project. Don't forget to give the project a star! ⭐ Thanks again!
This project was inspired by the innovative ideas shared by GitButler. Check out their video for more insights into enhancing Git workflows.
This project is licensed under the MIT License - see the LICENSE.md file for details.
-
Q: How do I add a description to a branch?
- A: Use the following command:
git branch --edit-description
- A: Use the following command:
-
Q: Can I use this instead of the standard
git branch
command?- A: B-branch only helps developers view branch information. It does not replace the standard
git branch
command.
- A: B-branch only helps developers view branch information. It does not replace the standard
-
Q: Will B-branch slow down git?
- A: No, the extension works with an alias and does not affect the performance of git.
-
Q: What is a common use case for B-branch?
- A: A common use case I use is to check how many commits I am behind or ahead of the upstream main branch. To see if I need to pull or merge the changes. This can be done by running
git bb -t "origin/main"
.
- A: A common use case I use is to check how many commits I am behind or ahead of the upstream main branch. To see if I need to pull or merge the changes. This can be done by running