Reputation: 403
I have my own repository. What I want to do is to change the history. I want to change the date of every single commit. Is it possible, if yes - how? I searched on google, but I didn't really find an answer.
P.s: My repository is in BitBucket and I'm using git core.
Upvotes: 0
Views: 120
Reputation: 1322975
Note that you have two dates to set:
GIT_AUTHOR_DATE
GIT_COMMITTER_DATE
They both follow the same date format
As in this blog post, resetting the dates on one specific SHA1 would be (using git filter-branch
):
git filter-branch --env-filter \
"if test \$GIT_COMMIT = 'e6dbcffca68e4b51887ef660e2389052193ba4f4'
then
export GIT_AUTHOR_DATE='Sat, 14 Dec 2013 12:40:00 +0000'
export GIT_COMMITTER_DATE='Sat, 14 Dec 2013 12:40:00 +0000'
fi" && rm -fr "$(git rev-parse --git-dir)/refs/original/"
Resetting commit fate to author date would be:
git filter-branch --env-filter 'export GIT_COMMITTER_DATE="$GIT_AUTHOR_DATE"'
You will have to do a git push --force
after changing the history, which can be problematic if others have cloned your upstream repo.
Upvotes: 1