Infrastructure

Tips to Be a Good Code Reviewer

# Tips to Be a Good Code Reviewer Reviewing other people’s code is an important skill as a software engineer. Here are some tips to be a good code reviewer. General Rule Generally speaking, we should prioritise PR over your task if you are assigned as a reviewer. Any lingering …

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. …