The scripts are meant to be installed in a users' home directory. To do this
quickly the Makefile
in the root of the repository has a target called
user_install
.
$ make user_install
Install git-helpers under /home/uroesch/bin
-> Installing bin/git-autorebase to /home/uroesch/bin/git-autorebase
-> Installing bin/git-fpc to /home/uroesch/bin/git-fpc
-> Installing bin/git-opush to /home/uroesch/bin/git-opush
-> Installing bin/git-rank to /home/uroesch/bin/git-rank
-> Installing bin/git-stale-branches to /home/uroesch/bin/git-stale-branches
-> Installing bin/git-walktree to /home/uroesch/bin/git-walktree
-> Installing bin/git-worklog to /home/uroesch/bin/git-worklog
-> Installing bin/strip-trailing-whitespace to
/home/uroesch/bin/strip-trailing-whitespace
FPC
stands for fetch, prune clean. It is meant to be used to be used after
a pull request was merged. Essentially it will switch to master
or main
and
pull
the new version. Then run fetch --prune
, gather the deleted remote
branches and delete them locally.
Usage:
git fpc [options]
Options:
-h | --help This message
-b | --base Set the default base branch
Default: 'main' or 'master'
-V | --version Display version and exit
Description:
Small script to pull master, fetch prune and delete matching local branches
FPC stands for fetch, prune and consolidate
In case your repository’s default branch is something other than master
or
main
you can add your default branch to the DEFAULT_BASES
array. E.g to
include the branch named production
to the git-fpc
script append the value
to the array:
declare -a DEFAULT_BASES=( master main production )
The autorebase
command assumes there are multiple local branches that need
synchronizing with master
or main
. It is basically a glorified loop changing
into each branch and executing git rebase (master|main)
.
Usage:
git autorebase [options]
Options:
-h | --help This message
-p | --push Push rebased repos to upstream
-b | --base Set the default base branch
Default: 'main' or 'master'
-x | --exclude <branch,..> Exclude branches from being rebased.
Separate branches with commas.
-V | --version Display version and exit
Description:
Small script to pull the master/main branch and then rebase all other
branches sequentially to master/main.
In case your repository’s default branch is something other than master
or
main
you can add your default branch to the DEFAULT_BASES
array. E.g to
include the branch named production
to the git-autorebase
script append the
value to the array:
declare -a DEFAULT_BASES=( master main production )
This is a shortcut for the command git push origin <branch>
. Pushes every
branch but master
or main
. With option -f
does force push and -r
removes
a remote branch.
Usage:
git opush [options]
Options:
-h | --help This message
-f | --force Force a push to upstream
-r | --remove Remove the repository from upstream
-b | --base Set the default base branch
Default: 'main' or 'master'
-V | --version Display version and exit
Description:
Origin push to upstream without a fuss. Excludes pushes to master/main.
In case your repository’s default branch is something other than master
or
main
you can add your default branch to the DEFAULT_BASES
array. E.g to
include the branch named production
to the git-autorebase
script append the
value to the array:
declare -a DEFAULT_BASES=( master main production )
A tiny helper to show the how many commits each commiter has made based on
git shortlog
Usage:
git rank [options]
Options:
-h | --help This message
-V | --version Display version and exit
Description:
Script to show a ranking based on git shortlog.
List the stale branches as a list showing the date in ISO format followed by the branch name. The default time threshold is set to 5 weeks.
Usage:
git stale branches [options]
Options:
-h | --help This message
-t | --threshold <string> Human readable string like "1 day ago"
-p | --per-week Create a list of stale branches divided by week.
-V | --version Display version and exit
$ git stale-branches
Last Commit Committer Branch name
------------------- -------------------- -------------------------------------
2022-05-19 23:22:41 Wiley E. Coyote bugfix/stackoverflow
$ git stale-branches -p
14 weeks ago
------------------- ------------------------------------------------------------
2021-12-29 16:15:13 experimental/ocrpdf
2021-12-29 16:19:50 packaging/debian
10 weeks ago
------------------- ------------------------------------------------------------
2022-01-26 23:03:29 main
2022-01-26 23:25:07 feature/scan2pdf
Walktree is not really a helper. Wrote it to demonstrate how git objects are linked in relation to each other. Used to visualize it for a Git Course I wrote.
The sample output below shows all objects and how they are linked together. This is mainly meant to teach newcomers to git how the underbelly of the beast functions.
commit HEAD
+ tree 7527799f603140237265cec303165533152cd059
+ blob 2f945df9add136a0922041000b2979b6c9d1e81e .gitattributes
+ blob 1e7eabe5f1514eebf7d7abad1de726b514889871 .gitignore
+ tree 23156938ebc1c46acf68827081925e1a65427e05 App
+ tree 9ab74ed98727ca90f6cbaf0c9aeeba8fe00ab7b3 AppInfo
+ tree ce102c8179bcf3114efab0a8ad3748860fb84f52 Launcher
+ blob 11b145e1401cf7b678d6bb2926d102fbdd97e724 JoplinPortable.ini
+ blob 39c7da0416a2beffbf7beab9d06c8c15c4628aa4 appicon.ico
+ blob 5d5865ecd45be90194a347b6c4cc81ec8e1ab699 appicon_128.png
+ blob e65cfaed2eca51cfd33098fbdbebf24f164e1f47 appicon_16.png
+ blob ef881abd1b466c497e4b8c206b879f75cac07d55 appicon_256.png
+ blob 828f503182eff7a6e8322be79a17028af3f04bab appicon_32.png
+ blob d5f6fb14d8a22cd5a6f02488fa37ba0160a1a150 appicon_48.png
+ blob 31dbd5d7e6e264871ba187a14b19436a53e4d901 appicon_75.png
+ blob b8626dabf082b0bb5f31503ec66d4f6bf8c8a00f appinfo.ini
+ blob b2e59de73d67909a36689a9ba21cdd667f6e2844 installer.ini
+ blob 9b5aa8bb506bc7f8c96e19110bf79623002abe01 update.ini
+ tree 347b6dc9cf1e978b355b5f652a06b88df11b08c3 Other
+ tree 84da419e374719d292f50b96cf7722a206c3a5df Update
+ blob f9016721a48ed8234d459ffe398f46d5804e11c0 Update.ps1
+ blob 6a02755f2781afb78c3af6e2a4d2e98eaa343c0e README.md
+ blob 1d2f9cf3d374d888e2fae3b684590c2f4d293bc4 help.html
Worklog creates a tabular log for the last week or any other number of days or weeks specifiable. By default it filters the current user’s commits but there is an option to specify a different users.
Shows a list of commits for last week for current users.
$ git worklog
Hash Timestamp Committer Subject
-------- ------------------- --------------- ---------------------------------
d61af8e 2022-05-31 20:24:05 Urs Roesch Use env instead path to bash
9906dd9 2022-05-27 23:41:26 Urs Roesch Make Makefile more generic
Usage:
git worklog [options]
Options:
-h | --help This message
-a | --author <name> Set the author's name as commit filter.
Default: Current user as specfied in git config.
-d | --day Show commits for last 24 hours of author.
-D | --days <N> Show commits for the number of days specified.
-w | --week Show commits for week of author.
-W | --weeks <N> Show commits for the number of weeks specified.
-V | --version Display version and exit
Description:
Show a tabular list of commits with the short hash, the author and the
subject. Unless specified the default ist to show one week worth of the
commit log for the current user.
When called within a git workspace and without file arguments the scripts works on changed files both in workspace or in the cache.
Invoking strip-trailing-whitespace
with file arguments it will skip the git
changed file detection and only work on the provided files.
Besides removing any trailing white space from files it also removes trailing newlines from a file.
Usage:
strip-trailing-whitespace [options] [<file> [..]]
Options:
-h | --help This message
-q | --quiet Suppress output of file names.
-V | --version Display version and exit
Description:
strip-trailing-whitespace does exactly what the name suggests.
Remove trailing whitespace from the each line of a text file.
Additionally chops off excessive new lines at file end.
When invoked without a file argument the current directory
is checked for git compliance and changed files in the
workspace or in the cache are changed.
Note: Not tested with binary files. Use at your own risk!