Git utility scripts
- Place these scripts in a persistent location.
- Add the location to
PATH
.
mkdir -p ~/.local/bin; \
git clone https://github.com/AndrewMJordan/git-tools ~/.local/bin/git-tools; \
export PATH="$PATH:$HOME/.local/bin/git-tools";
Opens the repository in your default web browser
Note: only GitHub, GitLab, and BitBucket remotes are supported
The environment variable
BROWSER
must be set.
Manages tags using semantic versioning
Prints whether the current directory is in a git repository
Commits all modified + untracked files
Prints all git repositories in the current directory (and all child directories)
Creates (or updates) a production branch from main, then pushes the branch
See GitLab Flow
Pushes the branch to origin
and sets up remote tracking
$ git publish [-c|--create [-a|--merge-when-pipeline-succeeds]]
Option | Description |
---|---|
create |
Creates a merge request for this branch. The merge request details are formatted for automatic issue closing. |
merge-when-pipeline-succeeds |
Automatically merges the merge request if the pipeline succeeds. |
See GitLab push options for more information.
Clones a repository to a fixed location
For example, running git deposit https://gitlab.com/group/subgroup/project.git
would clone the repository to ~/repos/gitlab/group/subgroup/project
.
FAQ: Why isn't the path shortened?
Git can be configured to apply different settings depending on the path to the repository (see gitconfig conditional includes). By keeping the full path, Git can correctly examine the path and determine which settings to apply.
For example:
[includeIf "gitdir:**/FangCompany/**"]
path = ~/work.gitconfig
[includeIf "gitdir:**/MyPersonalCompany/**"]
path = ~/home.gitconfig
If environment variable XDG_REPOS_HOME
is set, the repository is cloned to XDG_REPOS_HOME
. Otherwise, the repository is cloned to ~/repos
.
More on
XDG
environment variables here
Prints git-related user information based on the current directory
Manages feature branches
$ git feature start foo
$ git feature drop foo
$ git feature prune
Synchronizes the local repository with the remote