/git-util

Utilities for Git

Primary LanguageShellMIT LicenseMIT

git-util

Utilities for Git

ℹ️ DISCLAIMER

I'm not a programmer... So no maintenance for this repository is guaranteed. Everything is subject to my availability and mood. Thanks for understanding.

Install

Add the following lines in your bash profile (e.g., ~/.bashrc)

export GITUTIL_DIR="/directory/to/this/repository" # Change this path !
export PATH="${GITUTIL_DIR}":$PATH
alias gu='git-util' # an alias to save your fingers
source "${GITUTIL_DIR}/.git-util_completion"
source "${GITUTIL_DIR}/.git-util_aliases" # add this line if you wish to use autogenerated aliases for jumping to the directory of one repo.

List of Actions

Command Description
git-util list list all repositories under your $HOME folder.
git-util info list infomation of all your repos: repo name, category, current branch, relation with remote, and any uncommited change.
git-util sync Automatically do what's necessary (pull/push) for all your repos. Will NOT do anything if there are uncommited changes.
git-util save Similar to git-util sync, but will add and commit any uncommited changes and push to origin.
git-util alias Generate/update the .git-util_aliases file which contains aliases for quickly jumping to directories of your repo. use command cd]reponame to jump to the directory of repo reponame.
git-util ignore <repo1> <repo2> ... Tell the program to ignore a certain repo or cetain repos. <repo> can be either the name or the directory of the repo.
git-util ignore-reset Reset the ignore list by deleting the .git-util_ignore file.

Auto-completion

This program provide auto-completion of commands.

$ git-util <TAB><TAB>
alias         ignore        ignore-reset  info          list          save          sync
$ git-util i<TAB><TAB>
ignore        ignore-reset  info

Aliases to quickly jump to repository directory

Make sure the following line is added in your bash profile.

source "${GITUTIL_DIR}/.git-util_aliases" # ${GITUTIL_DIR} is path to this repository

For fisrt-time usage, type the following command to generate the .git-util_alilases file which contains the aliases.

git-util alias

To use it, just type cd] followed by the name of the target repository.

[user@hostname:~]$ cd]<TAB><TAB>
cd]git-util      cd]repo1      cd]repo2
[user@hostname:~]$ cd]repo1
[user@hostname:~/path/to/repo1]$ 

When your list of repo changes, update the aliases using this command again.

git-util alias

Customization

Some behaviors of the program can be customized by creating a file named config using the template config.template under the root directory. Please refer to config.template for what can be customized.