Archive for the 'Shell Script' Category

git-shift: Changing commit timestamps in Git

Monday, March 1st, 2010

Git is known to be so flexible that one can even fix or delete old commits, but what would you do if you wanted to change the timestamp of a particular commit? This need can arise for various reasons, such as when a merged commit has picked the unwanted timestamp on squash, when a contributor’s (or your notebook’s) machine clock was obviously far out of sync, and so on.
git-shift is the tool I wrote to change dates (timestamps) of specified commits in a git repository.  The choice of the name sounds a bit too bold, so maybe I will rename it later—but anyway.
The usage is simple; specify the amount of time you want to shift timestamps by, and a list of commit IDs you want to change timestamps of. (Range notation is currently not supported)
e.g. to move timestamps of commits identified by the IDs f9e8d7c6 and 579acf two hours backwards:

$ git-shift -2h f9e8d7c6 579acf

Use it wisely and enjoy your life, night and day workers! :D

git-info: Displaying information about a Git repository a la `svn info’

Sunday, November 8th, 2009

I haven’t been writing much in English about technical stuff, so I am going to start this blog with a series of articles that introduce some of my little works.

I picked git-info(1) to begin with, which is a small shell script that provides Git with a similar functionality to "svn info".  As a long time user of Subversion who was new to Git I really missed a handy command to see repository information at a glance, so I wrote this.

knu’s git-info at master – GitHub

A sample output (at the time of writing) is as follows.

% git info
Repository Path: /home/knu/src/github/git-info/.git
Path: /home/knu/src/github/git-info
Remote Repositories:
    origin  git@github.com:knu/git-info.git (fetch)
    origin  git@github.com:knu/git-info.git (push)
Remote Branches:
      origin/HEAD -> origin/master
      origin/master
Local Branches:
    * master
Repository Configuration:
    [core]
        repositoryformatversion = 0
        filemode = true
        bare = false
        logallrefupdates = true
    [remote "origin"]
        fetch = +refs/heads/*:refs/remotes/origin/*
        url = git@github.com:knu/git-info.git
    [branch "master"]
        remote = origin
        merge = refs/heads/master
Last Changed Commit ID: da32fa59f7fab84606ce3c144e636043e96d8063
Last Changed Author: Akinori MUSHA
Last Changed Date: Tue Jul 28 10:37:09 2009 +0900
Last Changed Log:
    Take the directory as a physical path.

Hope this helps you on your way.