I need to push some code upstream into my repo. However I would like to see if It is possible to set the date of the commit/push to be something other than the current the date.This would mean if someone visited my github page and my desired date for the push was 00/00/00 it would show as 00/00/00 and NOT the current date.Is there anyway to do this?
Asked
Active
Viewed 1,770 times
2
-
Don't think it is possible. Look at https://docs.gitlab.com/ee/api/commits.html . The `committed_date` is probably to be set by github only. – jschnasse Nov 02 '20 at 14:25
-
Technically, you cannot change *anything* about any *existing* commit. What you can do is make a new (different) commit that's almost exactly the same as the existing commit, but has whatever it is that you want to be different, different. That's what `git commit --amend` does, but note that `00/00/0000` isn't possible as it's not a valid date. `2000-01-01` (note the `01`s) is a valid date. – torek Nov 02 '20 at 14:58
-
1Once you've made a new commit, you'll have to convince that other Git on GitHub to stop using the old commit and start using the new one. That generally requires `git push --force` or `git push --force-with-lease`. – torek Nov 02 '20 at 14:59
-
Does this answer your question? [How can one change the timestamp of an old commit in Git?](https://stackoverflow.com/questions/454734/how-can-one-change-the-timestamp-of-an-old-commit-in-git) – creativecreatorormaybenot Oct 04 '21 at 23:02
1 Answers
9
You can change the date of last commit:
git commit --amend --no-edit --date=now
or input date:
git commit --amend --no-edit --date="2020.11.02 12:00"
Jackkobec
- 4,782
- 28
- 29
-
Thanks .This does not change the date in my github repo profile.It does change the date of the commit in my local repo.I am looking for a way to have the change show up once I push the code upstream. – Aliman Nov 02 '20 at 14:07
-
This does *not* change the date of the last commit. It creates a new commit that has the same underlying tree. – William Pursell Sep 04 '21 at 12:10
-