DEV Community

Discussion on: I'm a Git Master, Ask Me Anything

 
jonlai profile image
Jonathan Lai

Various reasons. Git rebasing and merging skew with the dates, and one wants to make the timestamp of the recent commits to "look" more reasonable.

Anyhow, what I'm really looking for is a shortcut for modify git timestamps without doing the manual work of setting GIT_AUTHOR_DATE and GIT_COMMITER_DATE with stackoverflow.com/a/3896112 .

Any insights @gonedark ?

Thread Thread
 
phaberest profile image
Luca Stefano Sartori • Edited

@jonlai have you ever found a trick to get that alias to work?

My solution under zsh is

function gtime() {
    GIT_COMMITTER_DATE="$1" git commit --amend --no-edit --date "$1"
}

used as

gtime YYYY-MM-DDTHH:MM:SS

example

gtime 2020-04-22T23:10:20