DEV Community

loading...

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

Collapse
jonlai profile image
Jonathan Lai

@gonedark / Jason McCreary do you have a response for my previous question about redo'ing the timestamps of old git commits?

What shortcuts do you have similar to github.com/potatolabs/git-redate?

Thread Thread
gonedark profile image
Jason McCreary Ask Me Anything

What is the use case for needing to change the date?

Thread Thread
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