Tuesday April 11th, 2023 NCLUG Meeting

Bob Proulx bob at proulx.com
Wed Apr 12 17:29:43 UTC 2023


Tom Propst wrote:
> I use this alias on all my development machines to give a graph view of git
> branches similar to `tig --all`. You can replace all the options after
> `--graph` with `--all` to see everything.
>
> alias gl='git log --oneline --graph \
>            --tags \
>
>  --remotes={"origin/tom/*","origin/develop*","origin/main*","origin/master*"}
> \
>            --branches={"tom/*","develop*","main*","master*"}'
>
> My branches are typically prefixed `tom/`. This shows my branches in
> relation to the organization's primary branches.

I also vote +1 for using --graph.  And --oneline also compacts the
display nicely too.

I normally have a couple of git aliases installed into the git config
itself so that they appear as additional git commands.  One of them I
lamely call "mylog" emphasizing the local nature of it and is one I
use all of the time.

    [alias]
        mylog = log --decorate --abbrev-commit --graph --pretty=oneline --color
    # mylog
    #   --decorate print the ref names of any commits (HEAD, master)
    #   --abbrev-commit instead of 40-byte hex commit hashes use shorter partials
    #   --graph draw text graphical lines on left side
    #   --pretty=oneline <sha1> <title line> compact display
    #   --oneline shorthand for "--pretty=oneline --abbrev-commit"

Then use of it is like this.

    git mylog

or

    git mylog --all

or if there are too many branches making that too busy

    git mylog master origin

or if the project has switched terms

    git mylog maintrunk upstream

The result is like this following with the same tig-like character
graphics showing the branch relationships.

The git project itself has an extreme number of branches.  I much
prefer the rebase strategy myself.  But using git itself as an
example the --graph shows the forks and merges of history.

    rwp at madness:/var/tmp$ git clone https://git.kernel.org/pub/scm/git/git.git
    rwp at madness:/var/tmp$ cd git
    rwp at madness:/var/tmp/git$ git mylog
    * 9857273be0 (HEAD -> master, origin/master, origin/main, origin/HEAD) The ninth batch
    *   063cd850f2 Merge branch 'jk/use-perl-path-consistently'
    |\
    | * c1917156a0 t/lib-httpd: pass PERL_PATH to CGI scripts
    * |   96f4113ac0 Merge branch 'jc/clone-object-format-from-void'
    |\ \
    | * | 8b214c2e9d clone: propagate object-format when cloning from void
    * | |   a86083e25f Merge branch 'fc/doc-manpage-base-url-fix'
    |\ \ \
    | * | | 092df21dfc doc: remove manpage-base-url workaround
    | |/ /
    * | |   95e6111e7c Merge branch 'dw/doc-submittingpatches-grammofix'
    |\ \ \
    | * | | d0ea2ca1cf SubmittingPatches: clarify MUA discussion with "the"
    | | |/
    | |/|
    * | |   714be4c3ac Merge branch 'jx/cap-object-info-uninitialized-fix'
    |\ \ \
    | * | | dc12ee77ab object-info: init request_info before reading arg
    | |/ /
    * | |   30e04bcfa8 Merge branch 'ar/adjust-tests-for-the-index-fallout'
    |\ \ \
    | * | | 1ec40a83a5 t2107: fix mention of the_index.cache_changed
    | * | | 993d7085be t3060: fix mention of function prune_index
    * | | |   647a2bb3ff Merge branch 'jc/spell-id-in-both-caps-in-message-id'
    |\ \ \ \
    | * | | | ba4324c4e1 e-mail workflow: Message-ID is spelled with ID in both capital letters
    * | | | |   d02343b599 Merge branch 'ws/sparse-check-rules'
    |\ \ \ \ \
    | * | | | | 00408adeac builtin/sparse-checkout: add check-rules command
    | * | | | | 24fc2cde64 builtin/sparse-checkout: remove NEED_WORK_TREE flag
    * | | | | | f285f68a13 mailmap: change primary address for Emily Shaffer
    * | | | | | 0607f793cb The eighth batch
    * | | | | |   89833fc249 Merge branch 'ds/fetch-bundle-uri-with-all'
    |\ \ \ \ \ \
    | * | | | | | 25bccb4b79 fetch: download bundles once, even with --all

Most projects do not practice such extreme branching.  Thank goodness!
Paging down a few more pages shows that the branches and parallel
development widens out to literally hundreds of parallel branches.

If we go back into the early days of the git project from before the
crazy branching then we can see things that are a little more easy to
understand.

    * c64b9b8860 Reference documentation for the core git commands.
    *   74c7cfa875 Merge of http://members.cox.net/junkio/git-jc.git
    |\
    | *-----.   211232bae6 Octopus merge of the following five patches.
    | |\ \ \ \
    | | | | | * b28858bf65 Update diff engine for symlinks stored in the cache.
    | | | | * | 660265909f diff-cache shows differences for unmerged paths without --cache.
    | | | | |/
    | | | * / c4b83e618f Do not write out new index if nothing has changed.
    | | | |/
    | | * / 9e30dd7c0e Make git-prune-script executable again.
    | | |/
    | * / fc54a9c30c Update git-apply-patch-script for symbolic links.
    | |/
    * | d5f415e6f5 [PATCH] create subdirs for symlinks
    * | 42ea9cb286 Be more careful about tree entry modes.
    * | d5a72fd622 Fix git-resolve-script.
    * | db823d4a5a Fix symlink handling
    |/
    * ed4eeaf203 [PATCH] git: Mention the '-p' option in the usage help string if git-diff-tree.
    * 67cc5c4ef8 Split "git-pull-script" into two parts
    * 160c8433d9 git-diff-cache: add "-m" flag to match all non-checked-out files with the index.
    * 8ae0a8c514 [PATCH] git and symlinks as tracked content
    * 5210372fe4 [PATCH] Fix git rpush.
    * 2af87aae78 [PATCH] Fix git rpull.
    * 4bea3b6926 git-pull-script: do the diffstat also for the fast-forward case
    *   d0d0d0bd3c Merge http://members.cox.net/junkio/git-jc.git/
    |\
    | * 8a9d32b7e9 When the patch tries to create a new file and the file exists, abort.
    | * b46f0b6dfd Optimize diff-cache -p --cached
    | * 6fa28064b0 Terminate diff-* on non-zero exit from GIT_EXTERNAL_DIFF
    | * ae7c0c92c0 Git-prune-script loses blobs referenced from an uncommitted cache.
    | * fd0ffd3ad1 Short-cut error return path in git-local-pull.
    | * b2d62f161e Make git-*-pull say who wants them for missing objects.
    * | 4feb7a016a Make "git-prune-script" take all refs into account.
    * | 770896e548 Teach fsck-cache to accept non-commits for reachability analysis.
    * | 552e2bd12e Teach "git-pull-script" about alternate HEAD's to pull..
    * | 13019d4136 [PATCH] Fix memory leaks in git-fsck-cache
    * | 705acc5c94 git-pull-script: add a final "diffstat" to show the result of the merge.
    |/
    * a31c6d022e sha1_file: make the new sha1 object writing be coda-friendly.

It was a simpler time in the project then.

I strongly recommend a simpler branching strategy than git uses for
itself for most projects!  For myself I prefer the rebase strategy to
result in a straight line history.

Bob


More information about the NCLUG mailing list