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 …

Git

Should We Use Squash and Merge Option?

When we merge PR into the base branch, we have an option to do Squash and Merge. My preference is to use it all the time. Let’s talk about why this is the case. First of all, what do we want from our commit history? We want to have a …

Git

Deploying Jekyll Site to Github Page with Github Actions

I created my personal portfolio site with Jekyll. The site is simply chucked in the Github page. Now, it is time to use Github actions to deploy the site to the Github page repo every time I commit to master. Here is the code. I am not using the Jekyll …

Git

How to Add Private Key to SSH Agent with Git Bash

The ssh-agent provide a secure way to hold the private keys of remote server. It is a program that runs in the background. While you are logged into the system, it is storing your keys in memory. If you are using a SSH key with Git, the ssh-agent is used …

Git

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 …

Git

Find a Remote Branch and Fetch it to Local with Git

git branch -r can list all the remote branch. In any large scale application code base, you are likely to get heaps of branch names. By piping grep, we can narrow down the remote branch git branch -r | grep MDH-112 This gives us a fewer options. origin/MDH-112-dev-branch origin/MDH-112-experiment origin/MDH-112-delete …

Git

How to Roll Back Merge Commit on Master Branch with Git

When rolling back a merge commit, I prefer to do it with git revert because it creates a new commit. Using -m 1 indicates that this is a merge and we want to roll back to the parent commit on the master branch. -m 2 is used to specify the …

Git

How to Rename a Branch with Git

Renaming a local branch is easy by using git branch command option -m. For the remote branch, we can create a new remote branch by pushing the renamed branch and then deleting the old branch. Here are the steps. (1) checkout git checkout old-branch-name (2) rename git branch -m new-branch-name …

Git

How to Rebase with Git

Here are the steps to rebase from master with Git. After doing this a few times, rebase is not so scary any more. Rebase vs Merge can be contentious. Generally speaking, I prefer to rebase because it creates a cleaner history. (1) Make sure to be in the feature branch …

Git

Difference Between Git Reset and Revert

Git reset and revert are similar, but understanding the difference is important. They can both roll back the change you made. The differnce is that reset moves the pointer back to the commit you specify, while revert creates another commit at the end of the chain to cancel the change. …