Alternative to Squash Commit

If we have three commits that we want to squash as below, we can simply use git reset, add and commit to squash those changes into one commit.

commit edba792d5ea2aec40f413a23bf539fa25270da65
Author: mdh
Date:   Thu Feb 27 09:00:16 2020 +1100

    Updated model3

commit 8ea10ef480c8cde59b2d78ae0fbe5367f877e59d
Author: mdh
Date:   Thu Feb 27 08:59:51 2020 +1100

    Updated model 2

commit d5da1aed0b45d546e95e9bc01207d73a115ef337
Author: mdh
Date:   Thu Feb 27 08:59:20 2020 +1100

    updated model

commit 7bd22703c418ffa9bd92cbbb06fb92926776211e
Author: mdh
Date:   Thu Feb 27 08:58:36 2020 +1100

    initial commit

First, we reset to the initial commit. Reset unstage the change, but the change still remains.

$ git reset 7bd22703c418ffa9bd92cbbb06fb92926776211e
Unstaged changes after reset:
M       CsvProcessor/Models/UniversityRankingModel.cs
M       CsvProcessor/Program.cs

Then, we can add and commit as usual. It will create a single commit with all the changes.

commit dc41d5ae2950b962c5cc5313caa1160429db8d25 (HEAD -> squash-test)
Author: mdh
Date:   Thu Feb 27 09:21:25 2020 +1100

    model update

commit 7bd22703c418ffa9bd92cbbb06fb92926776211e
Author: mdh
Date:   Thu Feb 27 08:58:36 2020 +1100

    initial commit

Of course, you can try to rebase -i on the number of commit or sha

> git rebase -i HEAD~3 (this means rebasing in the last 3 commits)
or
> git rebase -i [SHA]
or simply rebase to the master to see all the branch commit
> git rebase -i master

On the vim editor we can make the beginning of the commit as pick and the rest as squash. As rebasing changed the commit history, you need to force push to the remote branch.

pick 5641b70 model update1
squash 3c5fe33 model update2
squash 83b7e45 model update3

# Rebase 7bd2270..83b7e45 onto 7bd2270 (3 commands)
#
# Commands:
# p, pick  = use commit
# r, reword  = use commit, but edit the commit message
# e, edit  = use commit, but stop for amending
# s, squash  = use commit, but meld into previous commit
# f, fixup  = like "squash", but discard this commit's log message
# x, exec  = run command (the rest of the line) using shell
# d, drop  = remove commit
# l, label 
Git
How to specify which Node version to use in Github Actions

When you want to specify which Node version to use in your Github Actions, you can use actions/setup-node@v2. The alternative way is to use a node container. When you try to use a publicly available node container like runs-on: node:alpine-xx, the pipeline gets stuck in a queue. runs-on is not …

AWS
Using semantic-release with AWS CodePipeline and CodeBuild

Here is the usual pattern of getting the source from a git repository in AWS CodePipeline. In the pipeline, we use AWS CodeStart to connect to a repo and get the source. Then, we pass it to the other stages, like deploy or publish. For some unknown reasons, CodePipeline downloads …

DBA
mysqldump Error: Unknown table ‘COLUMN_STATISTICS’ in information_schema (1109)

mysqldump 8 enabled a new flag called columm-statistics by default. When you have MySQL client above 8 and try to run mysqldump on older MySQL versions, you will get the error below. mysqldump: Couldn’t execute ‘SELECT COLUMN_NAME, JSON_EXTRACT(HISTOGRAM ‘$”number-of-buckets-specified”‘) FROM information_schema.COLUMN_STATISTICS WHERE SCHEMA_NAME = ‘myschema’ AND TABLE_NAME = ‘craue_config_setting’;’: Unknown …