Git:- Git Commit – Comments – Changing Last Commits

Background

A couple of days ago, I made a few important code changes and thought it worthy to keep the changes.

Review Commit History – Before Any New Commits

Let us quickly review our commit history prior to this post.

git commit

git log

syntax


git log

sample


git log --pretty=format:"%cn %s %cd"

Output

Output – Image

Output – Text

>git log --pretty=format:"%cn %s %cd"
DanielAdeniji Adding README.md Wed Jul 21 08:22:09 2021 -0700
DanielAdeniji Initial Wed Jul 21 07:38:29 2021 -0700
DanielAdeniji first commit Wed Jul 21 07:36:18 2021 -0700

Explanation

  1. Issuing git log requesting the log to be formatted as “%cn %s %cd
    • The last log message was by …
    • It was entered on July 21st, 2021 at 8:22 AM
    • And, the message reads “Adding README.md”

Git Commit

Jumbled Commit

Issued a git commit.

From the console, entered a simple enough command.

The command reads “git commit -m …”

Unfortunately, the screen got jumbled up and ran ahead of me.

A few lines of empty lines and unprintable chattering.

Should have tried CTRL-C or something of the sort to cancel the commit session.

 

Review Commit History – Initial

Let us quickly review our commit history

git commit

git log

syntax


git log

sample


git log --pretty=format:"%cn %s %cd"

Output

Output – Image

Output – Text

>git log --pretty=format:"%cn %s %cd"
DanielAdeniji Unuseful message Mon Sep 6 14:13:35 2021 -0700
DanielAdeniji Adding README.md Wed Jul 21 08:22:09 2021 -0700
DanielAdeniji Initial Wed Jul 21 07:38:29 2021 -0700
DanielAdeniji first commit Wed Jul 21 07:36:18 2021 -0700

Explanation

  1. Issuing git log requesting the log to be formatted as “%cn %s %cd
    • The last log message was by …
    • It was entered on Sept 6th, 2021 at 2:13 PM
    • And, the message reads “Unuseful message”

 

Overwrite the Last Commit

Let us quickly clean up our last commit

git commit

syntax


git commit --amend

sample


git commit --amend -m "Adding new file gitLog.summary.cmd"

Output

Output – Image

Output – Text

>git commit --amend -m "Adding new file gitLog.summary.cmd"
[main 55e1b10] Adding new file gitLog.summary.cmd
Date: Mon Sep 6 14:13:35 2021 -0700
create mode 100644 gitLog.summary.cmd

Explanation

  1. Upon issuing “git commit“, git echoes back the comment we recorded and the list of file changes since the last commit

 

Review Commit History – Post

Post Correction, let us review our commit history

git log

git log

syntax


git log

sample


git log --pretty=format:"%cn %cd %s"

Output

Output – Image

Output – Text

>git log --pretty=format:"%cn %cd %s"
DanielAdeniji Mon Sep 6 14:18:29 2021 -0700 Adding new file gitLog.summary.cmd
DanielAdeniji Wed Jul 21 08:22:09 2021 -0700 Adding README.md
DanielAdeniji Wed Jul 21 07:38:29 2021 -0700 Initial
DanielAdeniji Wed Jul 21 07:36:18 2021 -0700 first commit

Explanation

  1. Issuing git log with a concise format ( git log –pretty=format:”%cn %cd %s” ) can help us quickly review our log messages
    • The last log message reads “Adding new file gitLog.summary.cmd
    • It was entered on Sept 6th, 2021 at 2:18 PM

GitHub

From GitHub, we are able to review commit histories.

To do so, please access the repository page.

And, click on the commit button.

Images

Image – Repository – Commits Button

Image – Repository – Commits Listing

Before Last Commit

Post Last Commit

Last Word

Linus Torvalds

The Register

GitHub merges ‘useless garbage’ says Linus Torvalds as new NTFS support added to Linux kernel 5.15
Also: Compiler warnings now treated as errors by default in kernel builds

By:- Tim Anderson

Link

Linus Torvalds will pull Paragon Software’s NTFS driver into the 5.15 kernel source – but he complained about the use of a GitHub merge in the submission, saying that GitHub “creates absolutely useless garbage merges.”

Early last month Torvalds gave Paragon Software a nudge that it really should submit a pull request – an actual submission of code to be merged into the kernel source – in order for its read-write NTFS driver to be included in the forthcoming 5.15 release, for which the merge window is currently open. NTFS is the native Windows file system and Paragon’s implementation will improve interoperability, versus the existing driver which has limited write support.

On Friday Paragon duly submitted its pull request, saying: “Current version works with normal/compressed/sparse files and supports acl, NTFS journal replaying.”

However, the company is still getting to grips with the submission process and Torvalds had several comments to make, intended to improve future pull requests.

First, he said the pull request should have been signed. “In a perfect world, it would be a PGP signature that I can trace directly to you through the chain of trust, but I’ve never actually required that,” he said.

Second, he noted that the code in the pull request included merge commits done with the GitHub web user interface. “That’s another of those things that I *really* don’t want to see – github creates absolutely useless garbage merges, and you should never ever use the github interfaces to merge anything,” he said.

He added: “[G]ithub is a perfectly fine hosting site, and it does a number of other things well too, but merges is not one of those things.”

Torvalds has complained about aspects of GitHub before, saying in 2012: “I don’t do github pull requests. github throws away all the relevant information, like having even a valid email address for the person asking me to pull. The diffstat is also deficient and useless.”

Note that the git request-pull command is different from the GitHub pull request feature. The ensuing forthright thread has more information on the subject.

Third, Paragon’s repository has commit messages which lack information, like “Merge branch ‘torvalds:master’ into master.”

Torvalds said that “Linux kernel merges need to be done *properly*.” He added: “That means proper commit messages with information about what is being merged and *why* you merge something. But it also means proper authorship and committer information etc. All of which github entirely screws up.”

An example of a well-commented change came from Torvalds yesterday, when he amended the Makefile used for compiling the kernel to “enable ‘-Werror’ by default for all kernel builds … but make it a config option so that broken environments can disable it when required.”

The meaning of -Werror is “Make all warnings into errors,” requiring stricter discipline for code that would otherwise compile but with warnings about suboptimal code.

Torvalds added that “we… will disable specific over-eager warnings as required, if we can’t fix them.”

“Hopefully this will mean that I get fewer pull requests that have new warnings that were not noticed by various automation we have in place… Knock wood,” he said. ®

 

My Take

I don’t believe this guy.

30 years later, he still thinks people are worthy of helpful nudges.

The outer persona of being cankerous must be a very, very thin shell.

References

  1. Atlassian
    • Git – Tutorials
      • Rewriting History
        Link

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s