• 31 May 2015

Use git reflog to restore reset commit

The last day of the workday of last week, my colleague told me that he lost his previous two days of work because he reset his local git commit to a prior one without pushing his work to the remote first. Upon receive this alarming news, while I have many other things to finalize, honestly my heart was virtually fall out. Fortunately, I believe in the power of git that it must be able to restore this thing! And sure enough, it turned out very easy to do:

      1. This assuming you are not yet run “git gc” ( garbage collector), so all the dangling commits are still available.
      2. Run the “git reflog” command (reflog starnds for reference log). This will list of series of history commits with short commit messages and SHA1s, including all those dangling commits. The short commit message is very helpful because normally you won’t remember your commit’s SHA1, but you recognize your commit message.
      3. Find the commit SHA1 you want to restore. For example, assume our commit needs to be restored here is [SHA33ddf]
      4. run “git branch [branchName] [SHA33ddf]”, this will create a new branch with the head point to this commit’s SHA1. Your work has magically restored!
      5. The last step would be setting up your new branch for tracking with the corresponding remote branch: “git branch -u upstream/branchName branchName”, assuming upstream is your remote origin.
  • 8 July 2014

Just another successful Git Branching Model for flexible sprint cycle

This Git Branching Strategy is based on the famous “Git Flow“ process (http://nvie.com/posts/a-successful-git-branching-model/ ). However, according to our project’s sepcific needs, we adapted the basic branching principle and made some modification on the original model. In the end, this branching model is shown by the picture below:

Git Branching Model illustration
Git Branching Model illustration


last comments

good thing that git has cheap branching.
James Ting
James Ting

What would be the meaning of the Main Branch?
David Adam

you mean the Master Branch?

  • 30 May 2011

Nicknames for types of your TMs

Do you know all what each of the following nickname mean? 🙂

  • The Attacker
  • The Complainer
  • The Comic
  • The Descerter
  • The Limelight Seeker
  • The Moonlighter
  • The Not-My-Jobber
  • The Bleeding Heart

  • 18 May 2011

Building team spirit

In order to build a team spirit, the following five factors are essential:

  1. Open communication
  2. Empowerment
  3. Clear roles and responsibilities
  4. An effective leader
  5. A reward and accountability system for both individual team members and the entire team.