Wilson Mar bio photo

Wilson Mar

Hello!

Calendar YouTube Github

LinkedIn

Helps you do your job

US (English)   Norsk (Norwegian)   Español (Spanish)   Français (French)   Deutsch (German)   Italiano   Português   Estonian   اَلْعَرَبِيَّةُ (Egypt Arabic)   Napali   中文 (简体) Chinese (Simplified)   日本語 Japanese   한국어 Korean

Overview

This page explains files in my git-utilities repo.

On a Mac:

  1. Get the repo onto your machine using a Git UI or in a Git command line:

    git clone https://github.com/wilsonmar/git-utilities
    
  2. cd into the repo.

  3. (If you don’t have it already) create a folder on the operating system’s path by copying the git-custom-commands folder from within the Git repository into a folder in your home directory.

    Linux people often use /opt/bin, but on a Mac that is a protected area requiring sudo access.

    create a folder under your $HOME folder and put that folder within the system path.

    $HOME/git-custom-commands
    
  4. On a Mac, edit file ~/.bash_profile so the custom command files will be found when they are run on any folder.

    PROTIP: git automatically make files available as a subcommand, just like regular executable scripts.

  5. Exit terminal session windows or re-run the Terminal initialization:

    source ~/.bash_profile
    
  6. cd into the git-custom-commands folder.

  7. Set permissions to execute each file:

    
    chmod 555 *
    
  8. Try the git-echo command, created just so we can verify whether we have it working:

    
    git echo "hello"
    

    You should see response:

    hello
    

    Instead of “hello”, you can type in any phrase.

Python program

A cross-platform Python can be executed.

Graphviz

Seth House did several videos on Git and GitHub, in which he showed use of a utility to create a visualization from the command line. He was nice enough to share it with me.

  1. Install GraphViz using a package manager. On a Mac:

    
    brew install graphviz
    

    This installs dependencies libtiff, webp, gd

    • http://www.graphviz.org/Download_macos.php - graphviz-2.40.1.pkg
    • http://www.graphviz.org/Download_windows.php

  2. Save the file from a text editor into folder

    Alternately, copy the file graph-dag into that folder from the cloned folder.

  3. Set permissions to execute the file:

    
    chmod a+x graph-dag
    
  4. Run the graph-dag that outputs a commit graph using the GraphViz “dot” tool:

    
    git graph-dag HEAD~10.. | dot -Tpng > mygraph.png
    
  5. Additionally, look at the other utilities at:

    https://git.wiki.kernel.org/index.php/ExampleScripts

    • Sorting commits by commit message line count / changed lines ratio
    • Copying all changed files from the last N commits
    • Setting the timestamps of the files to the commit timestamp of the commit which last touched them

Visualization of branches

git log does a good job of illustrating branches, but GitKraken provides this colorful branch graphics:

git-utilities gitkraken dag 579x279

  • The master branch is the light-blue line on the left.

  • The Bug fix branch is the darker-blue line to the right of that.

  • The develop branch is the purple line to the right of that.

ASCII Art

Make some ASCII art from (part of your) history

A - B - C
  \       \
    D - E - F
   

More

This is one of a series on Git and GitHub:

  1. Git and GitHub videos

  2. Why Git? (file-based backups vs Git clone)
  3. Git Markdown text

  4. Git basics (script)
  5. Git whoops (correct mistakes)
  6. Git messages (in commits)

  7. Git command shortcuts
  8. Git custom commands

  9. Git-client based workflows

  10. Git HEAD (Commitish references)

  11. Git interactive merge (imerge)
  12. Git patch
  13. Git rebase

  14. Git utilities
  15. Git-signing

  16. Git hooks
  17. GitHub data security
  18. TFS vs GitHub

  19. GitHub actions for automation JavaScript
  20. GitHub REST API
  21. GitHub GraphQL API
  22. GitHub PowerShell API Programming
  23. GitHub GraphQL PowerShell Module