Yes, we have aliases, and aliases do what they do best—take small one-liners and convert them into small useful Git commands. However, when it comes to larger scripts that are also a part of your process, and you would like to incorporate them into Git, you can simply name the script git-scriptname
, and then use it as git scriptname
.
There are a few things to remember. The script has to be in your path so that Git can use the script. Besides this, only imagination sets the boundary:
#!/bin/bash NUMBEROFCOMMITS=$(git log --all --oneline | wc -l) while : WHICHCOMMIT=$(( ( RANDOM % ${NUMBEROFCOMMITS} ) + 1 )) COMMITSUBJECT=$(git log --oneline --all -${WHICHCOMMIT} | tail -n1) COMMITSUBJECT_=$(echo $COMMITSUBJECT | cut -b0-60) do if [ $RANDOM -lt 14000 ]; then printf "e[1m%-60s e[32m%-10se[m " "${COMMITSUBJECT_}" ' PASSED' elif [ $RANDOM -gt 15000 ]; then printf "e[1m%-60s e[31m%-10se[m " "${COMMITSUBJECT_}" ' FAILED' fi Done
git-likeaboss
. This is a very simple script that will list random commit subjects with either passed or failed as the result. It will not stop until you press Ctrl + c.$ git likeaboss 5ec4977 Create a MergeResult for deleted/modified PASSED fcc3349 Add reflog message to TagCommand PASSED 591998c Do not allow non-ff-rebase if there are ed PASSED 0d7dd66 Make sure not to overwrite untracked notfil PASSED 5218f7b Propagate IOException where possible where FAILED f5fe2dc Teach PackWriter how to reuse an existing s FAILED
$ git likeboss git: 'likeboss' is not a git command. See 'git --help'. Did you mean this? likeaboss
I know this script in itself is not so useful in a day-to-day environment, but I hope you get the point I am trying to make. All scripts revolve around the software delivery chain and you can just as well name them Git as they are part of Git. This makes it much easier to remember which scripts you have are available for your job.