A set of helper scripts for the Git command line designed to automate repetitive tasks and keep your repository clean.
To ensure portability across different machines and operating systems without hardcoding paths, this repository includes setup scripts that register the installation directory as an environment variable (GIT_HELPERS).
Clone the repository and run the Bash installation script. This will add the GIT_HELPERS variable to your .bashrc or .profile.
git clone [https://github.com/bernardbr/git-helpers.git](https://github.com/bernardbr/git-helpers.git)
cd git-helpers
chmod +x install-env.sh
./install-env.shApply the changes:
source ~/.bashrcClone the repository and run the Zsh installation script optimized for macOS. This will add the GIT_HELPERS variable to your .zshrc.
git clone [https://github.com/bernardbr/git-helpers.git](https://github.com/bernardbr/git-helpers.git)
cd git-helpers
chmod +x install.zsh
./install.zshApply the changes:
source ~/.zshrcOnce the GIT_HELPERS variable is set, you can configure your global .gitconfig using the variable. This approach works natively on Linux, macOS, and WSL.
Open your global config (git config --global -e) and paste the following block:
[alias]
# Deletes local branches that are gone on the remote
delete-stale-branches = !bash "$GIT_HELPERS"/delete-stale-branches.sh
# Renames current branch locally and on remote
rename = !bash "$GIT_HELPERS"/rename-branch.sh
# Shows the latest tag
last-tag = !bash "$GIT_HELPERS"/show-last-tag.sh
# Deletes local tags that are gone on the remote
delete-stale-tags = !bash "$GIT_HELPERS"/delete-stale-tags.shAlternatively, you can run these commands one by one:
git config --global alias.delete-stale-branches '!bash "$GIT_HELPERS"/delete-stale-branches.sh'
git config --global alias.rename '!bash "$GIT_HELPERS"/rename-branch.sh'
git config --global alias.last-tag '!bash "$GIT_HELPERS"/show-last-tag.sh'
git config --global alias.delete-stale-tags '!bash "$GIT_HELPERS"/delete-stale-tags.sh'Checks for all local branches that no longer exist on the server (remote) and deletes them.
- Usage:
git delete-stale-branches
Renames both the local and remote branches while maintaining tracking.
- Usage:
git rename <new-branch-name>
Displays the latest tag created in the current tree.
- Usage:
git last-tag
Syncs your local tags with the remote, removing tags locally that were deleted on the server.
- Usage:
git delete-stale-tags
Made with ❤️ by Bernardo